Part Number Hot Search : 
FN3550 DM74LS85 STEF05D SB02W03C HPR122 AC10EGML IRH8250 D10NM6
Product Description
Full Text Search
 

To Download PIC12F635-ISNV04 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2007 microchip technology inc. ds41232d pic12f635/pic16f636/639 data sheet 8/14-pin, flash-based 8-bit cmos microcontrollers with nanowatt technology *8-bit, 8-pin devices protected by microchips low pin count patent: u. s. patent no. 5,847,450. additional u.s. and foreign patents and applications may be issued or pending. downloaded from: http:///
ds41232d-page ii ? 2007 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , k ee l oq logo, micro id , mplab, pic, picmicro, picstart, pro mate, powersmart, rfpic, and smartshunt are registered tr ademarks of microchip technology incorporated in the u.s.a. and other countries. amplab, filterlab, linear active thermistor, migratable memory, mxdev, mxlab, ps logo, seeval, smartsensor and the embedded control solutions company are registered trademarks of micr ochip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, ecan, economonitor, fansense, flexrom, fuzzylab, in-circuit serial programming, icsp, icepic, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, pickit, picdem, picdem.net, piclab, pictail, powercal, powerinfo, powermate, powe rtool, real ice, rflab, rfpicdem, select mode, smart serial, smarttel, total endurance, uni/o, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of mi crochip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2007, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the most secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specif ications contained in microchips data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as unbreakable. code protection is constantly evolving. we at microchip are committed to continuously improving the code protection features of our products. attempts to break microchips c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona, gresham, oregon and mountain view, california. the companys quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchips quality system for the design and manufacture of development systems is iso 9001:2000 certified. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 1 pic12f635/pic16f636/639 high-performance risc cpu: ? only 35 instructions to learn: - all single-cycle instructions except branches ? operating speed: - dc C 20 mhz oscillator/clock input - dc C 200 ns instruction cycle ? interrupt capability ? 8-level deep hardware stack ? direct, indirect and relative addressing modes special microcontroller features: ? precision internal oscillator: - factory calibrated to 1%, typical - software selectable frequency range of 8 mhz to 125 khz - software tunable - two-speed start-up mode - crystal fail detect for critical applications - clock mode switching during operation for power savings ? clock mode switching for low-power operation ? power-saving sleep mode ? wide operating voltage range (2.0v-5.5v) ? industrial and extended temperature range ? power-on reset (por) ? wake-up reset (wur) ? independent weak pull-up/pull-down resistors ? programmable low-voltage detect (plvd) ? power-up timer (pwrt) and oscillator start-up timer (ost) ? brown-out reset (bor) with software control option ? enhanced low-current watchdog timer (wdt) with on-chip oscillator (software selectable nominal 268 seconds with full prescaler) with software enable ? multiplexed master clear with pull-up/input pin ? programmable code protection (program and data independent) ? high-endurance flash/eeprom cell: - 100,000 write flash endurance - 1,000,000 write eeprom endurance - flash/data eeprom retention: > 40 years low-power features: ? standby current: - 1 na @ 2.0v, typical ? operating current: -8.5 a @ 32 khz, 2.0v, typical -100 a @ 1 mhz, 2.0v, typical ? watchdog timer current: -1 a @ 2.0v, typical peripheral features: ? 6/12 i/o pins with individual direction control: - high-current source/sink for direct led drive - interrupt-on-change pin - individually programmable weak pull-ups/ pull-downs - ultra low-power wake-up ? analog comparator module with: - up to two analog comparators - programmable on-chip voltage reference (cv ref ) module (% of v dd ) - comparator inputs and outputs externally accessible ? timer0: 8-bit timer/counter with 8-bit programmable prescaler ? enhanced timer1: - 16-bit timer/counter with prescaler - external timer1 gate (count enable) - option to use osc1 and osc2 in lp mode as timer1 oscillator if intosc mode selected ?k ee l oq ? compatible hardware cryptographic module ? in-circuit serial programming? (icsp?) via two pins low-frequency analog front-end features (pic16f639 only): ? three input pins for 125 khz lf input signals ? high input detection sensitivity (3 mv pp , typical) ? demodulated data, carrier clock or rssi output selection ? input carrier frequency: 125 khz, typical ? input modulation frequency: 4 khz, maximum ? 8 internal configuration registers ? bidirectional transponder communication (lf talk back) ? programmable antenna tuning capacitance (up to 63 pf, 1 pf/step) ? low standby current: 5 a (with 3 channels enabled), typical ? low operating current: 15 a (with 3 channels enabled), typical ? serial peripheral interface (spi) with internal mcu and external devices ? supports battery back-up mode and batteryless operation with external circuits 8/14-pin flash-based, 8-bi t cmos microcontrollers with nanowatt technology downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 2 ? 2007 microchip technology inc. device program memory data memory i/o comparators low frequency analog front-end flash (words) sram (bytes) eeprom (bytes) pic12f635 1024 64 128 6 1 n pic16f636 2048 128 256 12 2 n pic16f639 2048 128 256 12 2 y note 1: any references to porta, ran, trisa and trisan refe r to gpio, gpn, trisio and trision, respectively. 2: v ddt is the supply voltage of the analog front-end section (pic16f639 only). v ddt is treated as v dd in this document unless otherwise stated. 3: v sst is the ground reference voltage of the analog front-end section (pic16f639 onl y). v sst is treated as v ss in this document unless otherwise stated. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 3 pic12f635/pic16f636/639 8-pin diagrams (pdip, soic, dfn, dfn-s) table 1: 8-pin summary (pdip, soic, dfn, dfn-s) i/o pin comparators timer interrupts pull-ups basic gp0 7 c1in+ ioc y icspdat/ulpwu gp1 6 c1in- ioc y icspclk gp2 5 c1out t0cki int/ioc y gp3 (1) 4 i o c y (2) mclr /v pp gp4 3 t1g ioc y osc2/clkout gp5 2 t1cki ioc y osc1/clkin 1 v dd 8 v ss note 1: input only. 2: only when pin is configured for external mclr . pdip, soic pic12f635 v ss v dd gp5/t1cki/osc1/clkin gp4/t1g /osc2/clkout gp3/mclr /v pp gp0/c1in+/icspdat/ulpwu gp1/c1in-/icspclk gp2/t0cki/int/c1out 12 3 4 5 6 7 8 12 3 4 5 6 7 8 pic12f635 v ss gp0/cin+/icspdat/ulpwu gp1/cin-/icspclk gp2/t0cki/int/cout v dd gp5/t1cki/osc1/clkin gp4/t1g /osc2/clkout gp3/mclr /v dd dfn, dfn-s downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 4 ? 2007 microchip technology inc. 14-pin diagram (pdip, soic, tssop) table 2: 14-pin summary (pdip, soic, tssop) i/o pin comparators timer interrupts pull-ups basic ra0 13 c1in+ ioc y icspdat/ulpwu ra1 12 c1in- ioc y v ref /icspclk ra2 11 c1out t0cki int/ioc y ra3 (1) 4 i o c y (2) mclr /v pp ra4 3 t1g ioc y osc2/clkout ra5 2 t1cki ioc y osc1/clkin rc0 10 c2in+ rc1 9 c2in- rc2 8 r c 3 7 rc4 6 c2out r c 5 5 1 v dd 1 4 v ss note 1: input only. 2: only when pin is configured for external mclr . pic16f636 12 3 4 56 7 1413 12 9 11 10 8 v dd v ss ra5/t1cki/osc1/clkin ra4/t1g /osc2/clkout ra3/mclr /v pp ra0/c1in+/icspdat/ulpwu ra1/c1in-/v ref /icspclk ra2/t0cki/int/c1out rc5 rc4/c2out rc3 rc0/c2in+ rc1/c2in- rc2 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 5 pic12f635/pic16f636/639 16-pin diagram table 3: 16-pin summary i/o pin comparators timer interrupts pull-ups basic ra0 12 c1in+ ioc y icspdat/ulpwu ra1 11 c1in- ioc y v ref /icspclk ra2 10 c1out t0cki int/ioc y ra3 (1) 3 i o c y (2) mclr /v pp ra4 2 t1g ioc y osc2/clkout ra5 1 t1cki ioc y osc1/clkin rc0 9 c2in+ rc1 8 c2in- rc2 7 r c 3 6 rc4 5 c2out r c 5 4 16 v dd 1 3 v ss 14 nc 1 5 n c note 1: input only. 2: only when pin is configured for external mclr . 12 3 4 9 10 11 12 56 7 8 1615 14 13 pic16f636 v dd ncnc v ss ra5/t1cki/osc1/clkin ra4/an3/t1g/osc2/clkout ra3/mclr /v pp rc5 ra0/c1in+/icspdat/ulpwu ra1/c1in-/v ref /icspclk ra2/t0cki/int/c1out rc0/c2in+ rc4/c2out rc3rc2 rc1/c2in- qfn downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 6 ? 2007 microchip technology inc. 20-pin diagram table 4: 20-pin summary i/o pin analog front-end comparators timer interrupts pull-ups basic ra0 19 c1in+ ioc y icspdat/ulpwu ra1 18 c1in- ioc y v ref /icspclk ra2 17 c1out t0cki int/ioc y ra3 (1) 4 i o cy (2) mclr /v pp ra4 3 t1g ioc y osc2/clkout ra5 2 t1cki ioc y osc1/clkin rc0 16 c2in+ rc1 15 c2in- cs rc2 14 alert sclk rc3 7 lfdata/rssi cclk/sdio rc4 6 c2out rc5 5 8 v ddt (3) 1 3 v sst (4) 11 lcx 1 0 l c y 9 lcz 12 lccom 1 v dd 2 0 v ss note 1: input only. 2: only when pin is configured for external mclr . 3: v ddt is the supply voltage of the analog front-end section (pic16f639 only). v ddt is treated as v dd in this document unless otherwise stated. 4: v sst is the ground reference voltage of the analog front-end section (pic16f639 only). v sst is treated as v ss in this document unless otherwise stated. ssop pic16f639 v dd ra5/t1cki/osc1/clkin ra4/t1g /osc2/clkout ra3/mclr /v pp rc5 rc4/c2out rc3/lfdata/rssi/cclk/sdio v ddt (3) lcz lcy v ss ra0/c1in+/icspdat/ulpwu ra1/c1in-/v ref /icspclk ra2/tocki/int/c1out rc0/c2in+ rc1/c2in-/cs rc2/sclk/alert v sst (4) lccom lcx 12 3 4 2019 18 17 56 7 1615 14 89 10 1312 11 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 7 pic12f635/pic16f636/639 table of contents 1.0 device overview ....................................................... ...................................................... ............................................................. 9 2.0 memory organization .......................................... ................................................... ............ ........................................................ 17 3.0 clock sources .............................................................................. ................................. ............................................................. 35 4.0 i/o ports ......................................................................................... .......................... .................................................................. 47 5.0 timer0 module .............................................. ................................................... .............. ............................................................ 61 6.0 timer1 module with gate control...................................... ................................................... .... .................................................. 64 7.0 comparator module.......................................... ................................................... .............. ......................................................... 71 8.0 programmable low-voltage detect (plvd) module................................ ............................................... ................................... 87 9.0 data eeprom memory ..................................................................... ..................................... ................................................... 91 10.0 k ee l oq ? compatible cryptographic module ............................................ ................................................... .............................. 95 11.0 analog front-end (afe) functional description (pic16f639 only) ............................ ................................. ............................. 97 12.0 special features of the cpu...................................................... .......................................... .................................................... 129 13.0 instruction set summary ........................................................ ............................................ ...................................................... 149 14.0 development support............................................ ................................................... ......... ....................................................... 159 15.0 electrical specifications................................................... ............................................... .......................................................... 163 16.0 dc and ac characteristics graphs and tables................................... ............................................. ....................................... 191 17.0 packaging information................................................................ ...................................... ........................................................ 211 on-line support 223 systems information and upgrade hot line .................................... ................................................... .............................................. 223 reader response ................................................. ................................................... ............ ............................................................. 224 appendix a: data sheet revision history.................................... ................................................... . ................................................. 225 product identification system ................................................. .......................................................................................................... 231 worldwide sales and service ...................................................................... .............................. ....................................................... 232 to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regar ding this publication, please contact the marketing communications department via e-mail at docerrors@microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data sheet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/doc umentation issues become known to us, we will publis h an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particul ar device, please check with one of the following: ? microchips worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) when contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are using. customer notification system register on our web site at www.microchip.com to receive the most current information on all of our products. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 8 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 9 pic12f635/pic16f636/639 1.0 device overview this document contains device specific information for the pic12f635/pic16f636/639 devices. block diagrams and pinout descriptions of the devices are as follows: ? pic12f635 (figure 1-1, table 1-1) ? pic16f636 (figure 1-2, table 1-2) ? pic16f639 (figure 1-3, table 1-3) figure 1-1: pic12f 635 block diagram flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode and control timing generation osc1/clkin osc2/clkout gpio 8 8 8 3 8-level stack 64 bytes 1k x 14 (13-bit) power-up timer oscillator start-up timer power-on reset watchdog timer mclr v dd brown-out reset cryptographic timer0 timer1 data eeprom 128 bytes eedat eeaddr gp0 gp1 gp2 gp3 gp4 gp5 module t0cki t1cki configuration t1g 1 analog comparator and reference c1in- c1in+ c1out v ss programmable low-voltage detect wake-up reset 31 khz oscillator internal 8 mhz oscillator internal downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 10 ? 2007 microchip technology inc. figure 1-2: pic16f 636 block diagram flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg 8 8 8 3 8-level stack 128 2k x 14 bytes (13-bit) timer0 timer1 data eeprom 256 bytes eedat eeaddr t0cki t1cki configuration t1g portc rc0rc1 rc2 rc3 rc4 rc5 module 2 analog comparators and reference c1in- c1in+ c1out c2in- c2in+ c2out porta ra0ra1 ra2 ra3 ra4 ra5 power-up timer oscillator start-up timer power-on reset watchdog timer mclr v dd brown-out reset v ss programmable low-voltage detect wake-up reset instruction decode and control timing generation osc1/clkin osc2/clkout 31 khz oscillator internal 8 mhz oscillator internal cryptographic downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 11 pic12f635/pic16f636/639 figure 1-3: pic16f 639 block diagram flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr (1) 9 addr mux indirect addr fsr reg status reg mux alu w reg 8 8 8 3 8-level stack 128 2k x 14 bytes (13-bit) timer0 timer1 data eeprom 256 bytes eedat eeaddr t0cki configuration k eeloq module 2 analog comparators and reference c1in- c1in+ c1out c2in- c2in+ c2out portc rc0rc1 rc2 rc3 rc4 rc5 porta ra0ra1 ra2 ra3 ra4 ra5 v ddt lcx v sst lccom lcy lcz 125 khz (afe) power-up timer oscillator start-up timer power-on reset watchdog timer mclr v dd brown-out reset v ss programmable low-voltage detect wake-up reset analog front-end instruction decode and control timing generation osc1/clkin osc2/clkout 31 khz oscillator internal 8 mhz oscillator internal t1cki t1g downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 12 ? 2007 microchip technology inc. table 1-1: pic12f635 pinout descriptions name function input type output type description gp0/c1in+/icspdat/ulpwu gp0 ttl general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. selectable ultra low-power wake-up pin. c1in+ an comparator 1 input C positive. icspdat ttl cmos serial programming data i/o. ulpwu an ultra low-power wake-up input. gp1/c1in-/icspclk gp1 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. c1in- an comparator 1 input C negative. icspclk st serial programming clock. gp2/t0cki/int/c1out gp2 st cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t0cki st external clock for timer0. int st external interrupt. c1out cmos comparator 1 output. gp3/mclr /v pp gp3 ttl general purpose input. individually controlled interrupt-on-change. mclr st master clear reset. pull-up enabled when configured as mclr . v pp hv programming voltage. gp4/t1g /osc2/clkout gp4 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1g st timer1 gate. osc2 xtal xtal connection. clkout cmos t osc /4 reference clock. gp5/t1cki/osc1/clkin gp5 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1cki st timer1 clock. osc1 xtal xtal connection. clkin st t osc reference clock. v dd v dd d power supply for microcontroller. v ss v ss d ground reference for microcontroller. legend: an = analog input or output cmos = cmos compatible input or output d = direct hv = high voltage st = schmitt trigger input with cmos levels ttl = ttl compatible input xtal = crystal downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 13 pic12f635/pic16f636/639 table 1-2: pic16f636 pinout descriptions name function input type output type description ra0/c1in+/icspdat/ulpwu ra0 ttl general purpose i/o. individually controlled interrupt-on-change. indivi dually enabled pull-up/pull-down. selectable ultra low-power wake-up pin. c1in+ an comparator 1 input C positive. icspdat ttl cmos serial programming data i/o. ulpwu an ultra low-power wake-up input. ra1/c1in-/v ref /icspclk ra1 ttl cmos general purpose i/o. individually controlled interrupt-on-change. indivi dually enabled pull-up/pull-down. c1in- an comparator 1 input C negative. v ref an external voltage reference icspclk st serial programming clock. ra2/t0cki/int/c1out ra2 st cmos general purpose i/o. individually controlled interrupt-on-change. indivi dually enabled pull-up/pull-down. t0cki st external clock for timer0. int st external interrupt. c1out cmos comparator 1 output. ra3/mclr /v pp ra3 ttl general purpose input. indivi dually controlled interrupt-on-change. mclr st master clear reset. pull-up enabled when configured as mclr . v pp hv programming voltage. ra4/t1g /osc2/clkout ra4 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1g st timer1 gate. osc2 xtal xtal connection. clkout cmos t osc /4 reference clock. ra5/t1cki/osc1/clkin ra5 ttl cmos general purpose i /o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1cki st timer1 clock. osc1 xtal xtal connection. clkin st t osc reference clock. rc0/c2in+ rc0 ttl cmos general purpose i/o. c2in+ an comparator 1 input C positive. rc1/c2in- rc1 ttl cmos general purpose i/o. c2in- an comparator 1 input C negative. rc2 rc2 ttl cmos general purpose i/o. rc3 rc3 ttl cmos general purpose i/o. rc4/c2out rc4 ttl cmos general purpose i/o. c2out cmos comparator 2 output. rc5 rc5 ttl cmos general purpose i/o. v dd v dd d power supply for microcontroller. v ss v ss d ground reference for microcontroller. legend: an = analog input or output cmos = cmos compatible input or output d = direct hv = high voltage st = schmitt trigger input with cmos levels ttl = ttl compatible input xtal = crystal downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 14 ? 2007 microchip technology inc. table 1-3: pic16f639 pinout descriptions name function input type output type description lccom lccom an common reference for analog inputs. lcx lcx an 125 khz analog x channel input. lcy lcy an 125 khz analog y channel input. lcz lcz an 125 khz analog z channel input. ra0/c1in+/icspdat/ulpwu ra0 ttl general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. selectable ultra low-power wake-up pin. c1in+ an comparator1 input C positive. icspdat ttl cmos serial programming data io. ulpwu an ultra low-power wake-up input. ra1/c1in-/v ref /icspclk ra1 ttl cmos general purpose i/o. i ndividually controlled interrupt-on-change. individually enabled pull-up/pull-down. c1in- an comparator1 input C negative. v ref an external voltage reference icspclk st serial programming clock. ra2/t0cki/int/c1out ra2 st cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t0cki st external clock for timer0. int st external interrupt. c1out cmos comparator1 output. ra3/mclr /v pp ra3 ttl general purpose input. individually controlled interrupt-on-change. mclr st master clear reset. pull-up e nabled when configured as mclr . v pp hv programming voltage. ra4/t1g /osc2/clkout ra4 ttl cmos general purpose i/o. indivi dually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1g st timer1 gate. osc2 xtal xtal connection. clkout cmos t osc reference clock. ra5/t1cki/osc1/clkin ra5 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up/pull-down. t1cki st timer1 clock. osc1 xtal xtal connection. clkin st t osc /4 reference clock. rc0/c2in+ rc0 ttl cmos general purpose i/o. c2in+ an comparator1 input C positive. rc1/c2in-/cs rc1 ttl cmos general purpose i/o. c2in- an comparator1 input C negative. cs ttl chip select input for spi communication with internal pull-up resistor. rc2/sclk/alert rc2 ttl cmos general purpose i/o. sclk ttl digital clock input for spi communication. alert od output with internal pull-up resistor for afe error signal. legend: an = analog input or output cmos = cmos compatible input or output d = direct hv = high voltage st = schmitt trigger input with cmos levels od = open drain ttl = ttl compatible input xtal = crystal downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 15 pic12f635/pic16f636/639 rc3/lfdata/rssi/cclk/sdo rc3 ttl cmos general purpose i/o. lfdata cmos digital output representation of analog input signal to lc pins. rssi current received signal strength indicator. analog current that is proportional to input amplitude. cclk carrier clock output. sdio ttl cmos input/output for spi communication. rc4/c2out rc4 ttl cmos general purpose i/o. c2out cmos comparator2 output. rc5 rc5 ttl cmos general purpose i/o. v ddt v ddt d power supply for analog front-end. in this document, v ddt is treated the same as v dd , unless otherwise stated. v sst v sst d ground reference for analog front-end. in this document, v sst is treated the same as v ss , unless otherwise stated. v dd v dd d power supply for microcontroller. v ss v ss d ground reference for microcontroller. table 1-3: pic16f639 pinout descriptions (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output d = direct hv = high voltage st = schmitt trigger input with cmos levels od = open drain ttl = ttl compatible input xtal = crystal downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 16 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 17 pic12f635/pic16f636/639 2.0 memory organization 2.1 program memory organization the pic12f635/pic16f636/639 devices have a 13-bit program counter capable of addressing an 8k x 14 program memory space. only the first 1k x 14 (0000h-03ffh, for the pic12f635) and 2k x 14 (0000h-07ffh, for the pic16f636/639) is physically implemented. accessing a location above these boundaries will cause a wraparound within the first 2k x 14 space. the reset vector is at 0000h and the interrupt vector is at 0004h (see figure 2-1). 2.2 data memory organization the data memory (see figure 2-2) is partitioned into two banks, which contain the general purpose registers (gpr) and the special function registers (sfr). the special function registers are located in the first 32 locations of each bank. register locations 20h-7fh in bank 0 and a0h-bfh in bank 1 are gprs, implemented as static ram for the pic16f636/639. for the pic12f635, register locations 40h through 7fh are gprs implemented as static ram. register locations f0h-ffh in bank 1 point to addresses 70h-7fh in bank 0. all other ram is unimplemented and returns 0 when read. rp0 of the status register is the bank select bit. rp1 rp0 00 bank 0 is selected 01 bank 1 is selected 10 bank 2 is selected 11 bank 3 is selected figure 2-1: program memory map and stack of the pic12f635 figure 2-2: program memory map and stack of the pic16f636/639 pc<12:0> 13 0000h 0004h 0005h 03ffh 1fffh stack level 1 stack level 8 reset vector interrupt vector on-chip program memory call, return retfie, retlw 0400h access 0-3ffh pc<12:0> 13 0000h 0004h 0005h 07ffh 1fffh stack level 1 stack level 8 reset vector interrupt vector on-chip program memory call, return retfie, retlw 0800h access 0-7ffh downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 18 ? 2007 microchip technology inc. 2.2.1 general purpose register the register file is organized as 64 x 8 for the pic12f635 and 128 x 8 for the pic16f636/639. each register is accessed, either directly or indirectly, through the file select register, fsr (see section 2.4 indirect addressing, indf and fsr registers ). 2.2.2 special function registers the special function registers (sfrs) are registers used by the cpu and peripheral functions for controlling the desired operation of the device (see figure 2-1). these registers are static ram. the special registers can be classified into two sets: core and peripheral. the special function registers associated with the core are described in this section. those related to the operation of the peripheral features are described in the section of that peripheral feature. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 19 pic12f635/pic16f636/639 figure 2-3: pic12f635 special function registers file file file file address address address address indirect addr. (1) 00h indirect addr. (1) 80h accesses 00h-0bh 100h accesses 80h-8bh 180h tmr0 01h option_reg 81h 101h 181h pcl 02h pcl 82h 102h 182h status 03h status 83h 103h 183h fsr 04h fsr 84h 104h 184h gpio 05h trisio 85h 105h 185h 06h 86h 106h 186h 07h 87h 107h 187h 08h 88h 108h 188h 09h 89h 109h 189h pclath 0ah pclath 8ah 10ah 18ah intcon 0bh intcon 8bh 10bh 18bh pir1 0ch pie1 8ch 10ch 18ch 0dh 8dh 10dh 18dh tmr1l 0eh pcon 8eh 10eh 18eh tmr1h 0fh osccon 8fh 10fh 18fh t1con 10h osctune 90h crcon 110h 190h 11h 91h crdat0 (2) 111h 191h 12h 92h crdat1 (2) 112h 192h 13h 93h crdat2 (2) 113h 193h 14h lvdcon 94h crdat3 (2) 114h 194h 15h wpuda 95h 115h 195h 16h ioca 96h 116h 196h 17h wda 97h 117h 197h wdtcon 18h 98h 118h 198h cmcon0 19h vrcon 99h 119h 199h cmcon1 1ah eedat 9ah 11ah 19ah 1bh eeadr 9bh 11bh 19bh 1ch eecon1 9ch 11ch 19ch 1dh eecon2 (1) 9dh 11dh 19dh 1eh 9eh 11eh 19eh 1fh 9fh 11fh 19fh 20h 3fh a0h 120h 1a0h general purpose register 64 bytes 40h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses bank 0 1f0h 7fh ffh 17fh 1ffh b a n k 0b a n k 1b a n k 2b a n k 3 unimplemented data memory locations, read as 0 . note 1: not a physical register. 2: crdat<3:0> registers are k ee l oq ? hardware peripheral related registers and require the execution of the k ee l oq ? encoder license agreement regarding implementation of the module and access to related registers. the k ee l oq ? encoder license agreement may be accessed through the microchip web site located at www.microchip.com/k ee l oq or by contacting your local microchip sales representative. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 20 ? 2007 microchip technology inc. figure 2-4: pic16f636/639 special function registers file file file file address address address address indirect addr. (1) 00h indirect addr. (1) 80h accesses 00h-0bh 100h accesses 80h-8bh 180h tmr0 01h option_reg 81h 101h 181h pcl 02h pcl 82h 102h 182h status 03h status 83h 103h 183h fsr 04h fsr 84h 104h 184h porta 05h trisa 85h 105h 185h 06h 86h 106h 186h portc 07h trisc 87h 107h 187h 08h 88h 108h 188h 09h 89h 109h 189h pclath 0ah pclath 8ah 10ah 18ah intcon 0bh intcon 8bh 10bh 18bh pir1 0ch pie1 8ch 10ch 18ch 0dh 8dh 10dh 18dh tmr1l 0eh pcon 8eh 10eh 18eh tmr1h 0fh osccon 8fh 10fh 18fh t1con 10h osctune 90h crcon 110h 190h 11h 91h crdat0 (2) 111h 191h 12h 92h crdat1 (2) 112h 192h 13h 93h crdat2 (2) 113h 193h 14h lvdcon 94h crdat3 (2) 114h 194h 15h wpuda 95h 115h 195h 16h ioca 96h 116h 196h 17h wda 97h 117h 197h wdtcon 18h 98h 118h 198h cmcon0 19h vrcon 99h 119h 199h cmcon1 1ah eedat 9ah 11ah 19ah 1bh eeadr 9bh 11bh 19bh 1ch eecon1 9ch 11ch 19ch 1dh eecon2 (1) 9dh 11dh 19dh 1eh 9eh 11eh 19eh 1fh 9fh 11fh 19fh general purpose register 96 bytes 20h general purpose register 32 bytes a0hbfh 120h 1a0h c0h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses bank 0 1f0h 7fh ffh 17fh 1ffh b a n k 0b a n k 1b a n k 2b a n k 3 unimplemented data memory locations, read as 0 . note 1: not a physical register. 2: crdat<3:0> registers are k ee l oq hardware peripheral related registers and require the execution of the k ee l oq ? encoder license agreement regarding implementation of the module and access to related registers. the k ee l oq ? encoder license agreement may be accessed through the microchip web site located at www.microchip.com/k ee l oq or by contacting your local microchip sales representative. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 21 pic12f635/pic16f636/639 table 2-1: pic12f635 special function registers summary bank 0 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por/bor/ wur page bank 0 00h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 32,137 01h tmr0 timer0 module register xxxx xxxx 61,137 02h pcl program counters (pc) least significant byte 0000 0000 32,137 03h status irp rp1 rp0 to pd zd c c 0001 1xxx 26,137 04h fsr indirect data memory address pointer xxxx xxxx 32,137 05h gpio gp5 gp4 gp3 gp2 gp1 gp0 --xx xx00 47,137 06h unimplemented 07h unimplemented 08h unimplemented 09h unimplemented 0ah pclath write buffer for upper 5 bits of program counter ---0 0000 32,137 0bh intcon gie peie t0ie inte raie t0if intf raif (2) 0000 000x 28,137 0ch pir1 eeif lvdif crif c 1 i fo s f i f t m r 1 i f 000- 00-0 30,137 0dh unimplemented 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 xxxx xxxx 64,137 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 xxxx xxxx 64,137 10h t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 68,137 11h unimplemented 12h unimplemented 13h unimplemented 14h unimplemented 15h unimplemented 16h unimplemented 17h unimplemented 18h wdtcon wdtps3 wdtps2 wdtps1 wdtps0 swdten ---0 1000 144,137 19h cmcon0 c o u t cinv cis cm2 cm1 cm0 -0-0 0000 79,137 1ah cmcon1 t1gss cmsync ---- --10 82,137 1bh unimplemented 1ch unimplemented 1dh unimplemented 1eh unimplemented 1fh unimplemented legend: C = unimplemented locations read as 0 , u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: mclr and wdt reset do not affect the previous value data latch. the raif bit will be cleared upon reset but will set again if the m is- match exists. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 22 ? 2007 microchip technology inc. table 2-2: pic12f635 special function registers summary bank 1 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por/bor/ wur page bank 1 80h indf addressing this location uses c ontents of fsr to address data memory (not a physical register) xxxx xxxx 32,137 81h option_reg rapu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 63,137 82h pcl program counters (pc) least significant byte 0000 0000 32,137 83h status irp rp1 rp0 to pd zd cc 0001 1xxx 26,137 84h fsr indirect data memory address pointer xxxx xxxx 32,137 85h trisio trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 --11 1111 86h unimplemented 87h unimplemented 88h unimplemented 89h unimplemented 8ah pclath write buffer for upper 5 bits of program counter ---0 0000 32,137 8bh intcon gie peie t0ie inte raie t0if intf raif (3) 0000 000x 28,137 8ch pie1 eeie lvdie crie c 1 i eo s f i e t m r 1 i e 000- 00-0 29,137 8dh unimplemented 8eh pcon ulpwue sboren wur p o r bor --01 q-qq 31,137 8fh osccon ircf2 ircf1 ircf0 osts hts lts scs -110 q000 36,137 90h osctune tun4 tun3 tun2 tun1 tun0 ---0 0000 40,137 91h unimplemented 92h unimplemented 93h unimplemented 94h lvdcon i r v s tl v d e n lvdl2 lvdl1 lvdl0 --00 -000 --00 -000 95h wpuda (2) wpuda5 wpuda4 wpuda2 wpuda1 wpuda0 --11 -111 --11 -111 96h ioca ioca5 ioca4 ioca3 ioca2 ioca1 ioca0 --00 0000 --00 0000 97h wda (2) wda5 wda4 wda2wda1wda0 --11 -111 --11 -111 9bh unimplemented 99h vrcon vren v r r v r 3v r 2v r 1v r 0 0-0- 0000 0-0- 0000 9ah eedat eedat7 eedat6 eedat5 eedat4 eedat3 eedat2 eedat1 eedat0 0000 0000 0000 0000 9bh eeadr eeadr7 eeadr6 eeadr5 eeadr4 eeadr3 eeadr2 eeadr1 eeadr0 0000 0000 0000 0000 9ch eecon1 wrerr wren wr rd ---- x000 ---- q000 9dh eecon2 eeprom control register 2 (not a physical register) ---- ---- ---- ---- 9eh unimplemented 9fh unimplemented legend: C = unimplemented locations read as 0 , u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: gp3 pull-up is enabled when pin is configured as mclr in the configuration word register. 3: mclr and wdt reset do not affect the previous value data la tch. the raif bit will be cleared upon reset, but will set again if the mismatch exists. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 23 pic12f635/pic16f636/639 table 2-3: pic16f636/639 special function registers summary bank 0 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por/bor/ wur page bank 0 00h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 32,137 01h tmr0 timer0 module register xxxx xxxx 61,137 02h pcl program counters (pc) least significant byte 0000 0000 32,137 03h status irp rp1 rp0 to pd zd cc 0001 1xxx 26,137 04h fsr indirect data memory address pointer xxxx xxxx 32,137 05h porta ra5 ra4 ra3 ra2 ra1 ra0 --xx xx00 48,137 06h unimplemented 07h portc rc5 rc4 rc3 rc2 rc1 rc0 --xx xx00 57,137 08h unimplemented 09h unimplemented 0ah pclath write buffer for upper 5 bits of program counter ---0 0000 32,137 0bh intcon gie peie t0ie inte raie t0if intf raif (2) 0000 000x 28,137 0ch pir1 eeif lvdif crif c2if c1if osfif t m r 1 i f 0000 00-0 30,137 0dh unimplemented 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 xxxx xxxx 64,137 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 xxxx xxxx 64,137 10h t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 68,137 11h unimplemented 12h unimplemented 13h unimplemented 14h unimplemented 15h unimplemented 16h unimplemented 17h unimplemented 18h wdtcon wdtps3 wdtps2 wdtps1 wdtps0 swdten ---0 1000 144,137 19h cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 79,137 1ah cmcon1 t1gss c2sync ---- --10 82,137 1bh unimplemented 1ch unimplemented 1dh unimplemented 1eh unimplemented 1fh unimplemented legend: C = unimplemented locations read as 0 , u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: mclr and wdt reset do not affect the previous value data latch. the raif bit will be cleared upon reset but will set again if the mismatch exists. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 24 ? 2007 microchip technology inc. table 2-4: pic16f636/639 special function registers summary bank 1 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por/bor/ wur page bank 1 80h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 32,137 81h option_reg rapu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 63,137 82h pcl program counters (pc) least significant byte 0000 0000 32,137 83h status irp rp1 rp0 to pd zd cc 0001 1xxx 26,137 84h fsr indirect data memory address pointer xxxx xxxx 32,137 85h trisa trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 --11 1111 --11 1111 86h unimplemented 87h trisc trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 --11 1111 --11 1111 88h unimplemented 89h unimplemented 8ah pclath write buffer for upper 5 bits of program counter ---0 0000 32,137 8bh intcon gie peie t0ie inte raie t0if intf raif (3) 0000 000x 28,137 8ch pie1 eeie lvdie crie c2ie c1ie osfie t m r 1 i e 0000 00-0 29,137 8dh unimplemented 8eh pcon ulpwue sboren wur p o r bor --01 q-qq --0u u-uu 8fh osccon ircf2 ircf1 ircf0 osts hts lts scs -110 q000 -110 x000 90h osctune tun4 tun3 tun2 tun1 tun0 ---0 0000 ---u uuuu 91h unimplemented 92h unimplemented 93h unimplemented 94h lvdcon i r v s tl v d e n lvdl2 lvdl1 lvdl0 --00 -000 --00 -000 95h wpuda (2) wpuda5 wpuda4 wpuda2 wpuda1 wpuda0 --11 -111 --11 -111 96h ioca ioca5 ioca4 ioca3 ioca2 ioca1 ioca0 --00 0000 --00 0000 97h wda (2) wda5 wda4 wda2 wda1 wda0 --11 -111 --11 -111 9bh unimplemented 99h vrcon vren v r r vr3 vr2 vr1 vr0 0-0- 0000 0-0- 0000 9ah eedat eedat7 eedat6 eedat5 eedat4 eedat3 eedat2 eedat1 eedat0 0000 0000 0000 0000 9bh eeadr eeadr7 eeadr6 eeadr5 eeadr4 eeadr3 eeadr2 eeadr1 eeadr0 0000 0000 0000 0000 9ch eecon1 wrerr wren wr rd ---- x000 ---- q000 9dh eecon2 eeprom control register 2 (not a physical register) ---- ---- ---- ---- 9eh unimplemented 9fh unimplemented legend: C = unimplemented locations read as 0 , u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: ra3 pull-up is enabled when pin is configured as mclr in the configuration word register. 3: mclr and wdt reset do not affect the previous value data latch. the raif bit will be cleared upon reset but will set again if the mismatch exists. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 25 pic12f635/pic16f636/639 table 2-5: pic12f635/pic16f636/639 special function registers summary bank 2 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por/bor/ wur page bank 2 10ch unimplemented 10dh unimplemented 10eh unimplemented 10fh unimplemented 110h crcon go/done enc/dec crreg1 crreg0 00-- --00 00-- --00 111h crdat0 (2) cryptographic data register 0 0000 0000 0000 0000 112h crdat1 (2) cryptographic data register 1 0000 0000 0000 0000 113h crdat2 (2) cryptographic data register 2 0000 0000 0000 0000 114h crdat3 (2) cryptographic data register 3 0000 0000 0000 0000 115h unimplemented 116h unimplemented legend: C = unimplemented locations read as 0 , u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: crdat<3:0> registers are k ee l oq ? hardware peripheral related registers and require the execution of the k ee l oq encoder license agreement regarding implementation of the module and access to related registers. the k ee l oq encoder license agreement may be accessed through the mi crochip web site located at www.microchip.com/k ee l oq or by contacting your local microchip sales representative. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 26 ? 2007 microchip technology inc. 2.2.2.1 status register the status register, shown in register 2-1, contains: ? the arithmetic status of the alu ? the reset status ? the bank select bits for data memory (gpr and sfr) the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status, will clear the upper three bits and set the z bit. this leaves the status register as 000u u1uu? (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register, because these instructions do not affect any status bits. for other instructions not affect- ing any status bits, see section 13.0 instruction set summary note 1: the c and dc bits operate as a borrow and digit borrow out bit, respectively, in subtraction. register 2-1: status: status register r/w-0 r/w-0 r/w-0 r-1 r-1 r/w-x r/w-x r/w-x irp rp1 rp0 to pd zd c (1) c (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 irp: register bank select bit (used for indirect addressing) 1 = bank 2, 3 (100h-1ffh) 0 = bank 0, 1 (00h-ffh) bit 6-5 rp<1:0>: register bank select bits (used for direct addressing) 00 = bank 0 (00h-7fh) 01 = bank 1 (80h-ffh) 10 = bank 2 (100h-17fh) 11 = bank 3 (180h-1ffh) bit 4 to : time-out bit 1 = after power-up, clrwdt instruction or sleep instruction 0 = a wdt time-out occurred bit 3 pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2 z: zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1 dc: digit carry/borrow bit ( addwf , addlw,sublw,subwf instructions) (1) 1 = a carry-out from the 4th low-order bit of the result occurred 0 = no carry-out from the 4th low-order bit of the result bit 0 c: carry/borrow bit (1) ( addwf , addlw, sublw, subwf instructions) (1) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note 1: for borrow , the polarity is reversed. a subtraction is executed by adding the twos complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high-order or low-order bit of the source register. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 27 pic12f635/pic16f636/639 2.2.2.2 option register the option register is a readable and writable register which contains various control bits to configure: ? tmr0/wdt prescaler ? external ra2/int interrupt ?tmr0 ? weak pull-up/pull-downs on porta note: to achieve a 1:1 prescaler assignment for timer0, assign the prescaler to the wdt by setting the psa bit of the option register to 1 . see section 5.1.3 software programmable prescaler . register 2-2: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 rapu intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 rapu : porta pull-up enable bit 1 = porta pull-ups are disabled 0 = porta pull-ups are enabled by individual port latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of ra2/int pin 0 = interrupt on falling edge of ra2/int pin bit 5 t0cs: timer0 clock source select bit 1 = transition on ra2/t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: timer0 source edge select bit 1 = increment on high-to-low transition on ra2/t0cki pin 0 = increment on low-to-high transition on ra2/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits 000001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value timer0 rate wdt rate downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 28 ? 2007 microchip technology inc. 2.2.2.3 intcon register the intcon register is a readable and writable register which contains the various enable and flag bits for tmr0 register overflow, porta change and external ra2/int pin interrupts. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global interrupt enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 2-3: intcon: interrupt control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-x gie peie t0ie inte raie (1,3) t0if (2) intf raif bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 gie: global interrupt enable bit 1 = enables all unmasked interrupts 0 = disables all interrupts bit 6 peie: peripheral interrupt enable bit 1 = enables all unmasked peripheral interrupts 0 = disables all peripheral interrupts bit 5 t0ie: timer0 overflow interrupt enable bit 1 = enables the timer0 interrupt 0 = disables the timer0 interrupt bit 4 inte: ra2/int external interrupt enable bit 1 = enables the ra2/int external interrupt 0 = disables the ra2/int external interrupt bit 3 raie: porta change interrupt enable bit (1,3) 1 = enables the porta change interrupt 0 = disables the porta change interrupt bit 2 t0if: timer0 overflow interrupt flag bit (2) 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1 intf: ra2/int external interrupt flag bit 1 = the ra2/int external interrupt occurred (must be cleared in software) 0 = the ra2/int external interrupt did not occur bit 0 raif: porta change interrupt flag bit 1 = when at least one of the porta general purpose i/o pins changed state (must be cleared in software) 0 = none of the porta general purpose i/o pins have changed state note 1: ioca register must also be enabled. 2: t0if bit is set when timer0 rolls over. timer0 is unchanged on reset and should be initialized before clearing t0if bit. 3: includes ulpwu interrupt. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 29 pic12f635/pic16f636/639 2.2.2.4 pie1 register the pie1 register contains the interrupt enable bits, as shown in register 2-4. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 2-4: pie1: peripheral interrupt enable register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 eeie lvdie crie c2ie (1) c1ie osfie t m r 1 i e bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 eeie : ee write complete interrupt enable bit 1 = enables the ee write complete interrupt 0 = disables the ee write complete interrupt bit 6 lvdie : low-voltage detect interrupt enable bit 1 = enables the lvd interrupt 0 = disables the lvd interrupt bit 5 crie : cryptographic interrupt enable bit 1 = enables the cryptographic interrupt 0 = disables the cryptographic interrupt bit 4 c2ie : comparator 2 interrupt enable bit (1) 1 = enables the comparator 2 interrupt 0 = disables the comparator 2 interrupt bit 3 c1ie : comparator 1 interrupt enable bit 1 = enables the comparator 1 interrupt 0 = disables the comparator 1 interrupt bit 2 osfie : oscillator fail interrupt enable bit 1 = enables the oscillator fail interrupt 0 = disables the oscillator fail interrupt bit 1 unimplemented : read as 0 bit 0 tmr1ie: timer1 overflow interrupt enable bit 1 = enables the timer1 overflow interrupt 0 = disables the timer1 overflow interrupt note 1: pic16f636/639 only. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 30 ? 2007 microchip technology inc. 2.2.2.5 pir1 register the pir1 register contains the interrupt flag bits, as shown in register 2-5. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global interrupt enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 2-5: pir1: peripheral interrupt request register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 eeif lvdif crif c2if (1) c1if osfif t m r 1 i f bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 eeif : ee write complete interrupt flag bit 1 = the write operation completed (must be cleared in software) 0 = the write operation has not completed or has not been started bit 6 lvdif : low-voltage detect interrupt flag bit 1 = the supply voltage has crossed selected lvd voltage (must be cleared in software) 0 = the supply voltage has not crossed selected lvd voltage bit 5 crif : cryptographic interrupt flag bit 1 = the cryptographic module has completed an operation (must be cleared in software) 0 = the cryptographic module has not completed an operation or is idle bit 4 c2if : comparator 2 interrupt flag bit (1) 1 = comparator output (c2out bit) has changed (must be cleared in software) 0 = comparator output (c2out bit) has not changed bit 3 c1if : comparator 1 interrupt flag bit 1 = comparator output (c1out bit) has changed (must be cleared in software) 0 = comparator output (c1out bit) has not changed bit 2 osfif : oscillator fail interrupt flag bit 1 = system oscillator failed, clock input has changed intosc (must be cleared in software) 0 = system clock operating bit 1 unimplemented : read as 0 bit 0 tmr1if: timer1 overflow interrupt flag bit 1 = timer1 rolled over (must be cleared in software) 0 = timer1 has not rolled over note 1: pic16f636/639 only. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 31 pic12f635/pic16f636/639 2.2.2.6 pcon register the power control (pcon) register (see table 12-3) contains flag bits to differentiate between a: ? power-on reset (por ) ? wake-up reset (wur ) ? brown-out reset (bor ) ? watchdog timer reset (wdt) ? external mclr reset the pcon register also controls the ultra low-power wake-up and software enable of the bor . the pcon register bits are shown in register 2-6. register 2-6: pcon: power control register u-0 u-0 r/w-0 r/w-1 r/w-x u-0 r/w-0 r/w-x ulpwue sboren (1) wur p o r bor bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as 0 bit 5 ulpwue: ultra low-power wake-up enable bit 1 = ultra low-power wake-up enabled 0 = ultra low-power wake-up disabled bit 4 sboren: software bor enable bit (1) 1 = bor enabled 0 = bor disabled bit 3 wur : wake-up reset status bit 1 = no wake-up reset occurred 0 = a wake-up reset occurred (must be set in software after a power-on reset occurs) bit 2 unimplemented: read as 0 bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0 bor : brown-out reset status bit 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set in software after a brown-out reset occurs) note 1: boren<1:0> = 01 in the configuration word register for this bit to control the bor . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 32 ? 2007 microchip technology inc. 2.3 pcl and pclath the program counter (pc) is 13 bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<12:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 2-5 shows the two situations for the loading of the pc. the upper example in figure 2-5 shows how the pc is loaded on a write to pcl (pclath<4:0> pch). the lower example in figure 2-5 shows how the pc is loaded during a call or goto instruction (pclath<4:3> pch). figure 2-5: loading of pc in different situations 2.3.1 modifying pcl executing any instruction with the pcl register as the destination simultaneously causes the program counter pc<12:8> bits (pch) to be replaced by the contents of the pclath register. this allows the entire contents of the program counter to be changed by writing the desired upper 5 bits to the pclath register. when the lower 8 bits are written to the pcl register, all 13 bits of the program counter will change to the values contained in the pclath register and those being written to the pcl register. a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). care should be exercised when jumping into a look-up table or program branch table (computed goto ) by modifying the pcl register. assuming that pclath is set to the table start address, if the table length is greater than 255 instructions or if the lower 8 bits of the memory address rolls over from 0xff to 0x00 in the middle of the table, then pclath must be incremented for each address rollover that occurs between the table beginning and the target location within the table. for more information refer to application note an556, implementing a table read (ds00556). 2.3.2 stack the pic12f635/pic16f636/639 family has an 8-level x 13-bit wide hardware stack (see figure 2-1). the stack space is not part of either program or data space and the stack pointer is not readable or writable. the pc is pushed onto the stack when a call instruction is executed or an interrupt causes a branch. the stack is poped in the event of a return , retlw or a retfie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer. this means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored from the first push. the tenth push overwrites the second push (and so on). 2.4 indirect addressing, indf and fsr registers the indf register is not a physical register. addressing the indf register will cause indirect addressing. indirect addressing is possible by using the indf register. any instruction using the indf register actually accesses data pointed to by the file select register (fsr). reading indf itself indirectly will produce 00h. writing to the indf register indirectly results in a no operation (although status bits may be affected). an effective 9-bit address is obtained by concatenating the 8-bit fsr and the irp bit of the status register, as shown in figure 2-6. a simple program to clear ram location 20h-2fh using indirect addressing is shown in example 2-1. example 2-1: indirect addressing pc 12 8 7 0 5 pclath<4:0> pclath instruction with alu result goto , call opcode<10:0> 8 pc 12 11 10 0 11 pclath<4:3> pch pcl 87 2 pclath pch pcl pcl as destination note 1: there are no status bits to indicate stack overflow or stack underflow conditions. 2: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call , return , retlw and retfie instructions or the vectoring to an interrupt address. movlw 0x20 ;initialize pointer movwf fsr ;to ram next clrf indf ;clear indf register incf fsr ;inc pointer btfss fsr,4 ;all done? goto next ;no clear next continue ;yes continue downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 33 pic12f635/pic16f636/639 figure 2-6: direct/indirect addressing pic12f635/pic16f636/639 note: for memory map detail, see figure 2-2. data memory indirect addressing direct addressing bank select location select rp1 rp0 6 0 from opcode irp file select register 7 0 bank select location select 00 01 10 11 180h 1ffh 00h 7fh bank 0 bank 1 bank 2 bank 3 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 34 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 35 pic12f635/pic16f636/639 3.0 oscillator module (with fail-safe clock monitor) 3.1 overview the oscillator module has a wide variety of clock sources and selection features that allow it to be used in a wide range of applications while maximizing perfor- mance and minimizing power consumption. figure 3-1 illustrates a block diagram of the oscillator module. clock sources can be configured from external oscillators, quartz crystal resonators, ceramic resonators and resistor-capacitor (rc) circuits. in addition, the system clock source can be configured from one of two internal oscillators, with a choice of speeds selectable via software. additional clock features include: ? selectable system clock source between external or internal via software. ? two-speed start-up mode, which minimizes latency between external oscillator start-up and code execution. ? fail-safe clock monitor (fscm) designed to detect a failure of the external clock source (lp, xt, hs, ec or rc modes) and switch automatically to the internal oscillator. the oscillator module can be configured in one of eight clock modes. 1. ec C external clock with i/o on osc2/clkout. 2. lp C 32 khz low-power crystal mode. 3. xt C medium gain crystal or ceramic resonator oscillator mode. 4. hs C high gain crystal or ceramic resonator mode. 5. rc C external resistor-capacitor (rc) with f osc /4 output on osc2/clkout. 6. rcio C external resistor-capacitor (rc) with i/o on osc2/clkout. 7. intosc C internal oscillator with f osc /4 output on osc2 and i/o on osc1/clkin. 8. intoscio C internal oscillator with i/o on osc1/clkin and osc2/clkout. clock source modes are configured by the fosc<2:0> bits in the configuration word register (config). the internal clock can be generated from two internal oscillators. the hfintosc is a calibrated high-frequency oscillator. the lfintosc is an uncalibrated low-frequency oscillator. figure 3-1: pic ? mcu clock source block diagram (cpu and peripherals) osc1 osc2 sleep external oscillator lp, xt, hs, rc, rcio, ec system clock postscaler mux mux 8 mhz 4 mhz 2 mhz 1 mhz 500 khz 125 khz 250 khz ircf<2:0> 111110 101 100 011 010 001 000 31 khz power-up timer (pwrt) fosc<2:0> (configuration word register) scs<0> (osccon register) internal oscillator (osccon register) watchdog timer (wdt) fail-safe clock monitor (fscm) hfintosc 8 mhz lfintosc 31 khz intosc downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 36 ? 2007 microchip technology inc. 3.2 oscillator control the oscillator control (osccon) register (figure 3-1) controls the system clock and frequency selection options. the osccon register contains the following bits: ? frequency selection bits (ircf) ? frequency status bits (hts, lts) ? system clock control bits (osts, scs) register 3-1: osccon: oscillator control register u-0 r/w-1 r/w-1 r/w-0 r-1 r-0 r-0 r/w-0 ircf2 ircf1 ircf0 osts (1) hts lts scs bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 unimplemented: read as 0 bit 6-4 ircf<2:0>: internal oscillator frequency select bits 111 =8mhz 110 = 4 mhz (default) 101 =2mhz 100 =1mhz 011 =500khz 010 =250khz 001 =125khz 000 = 31 khz (lfintosc) bit 3 osts: oscillator start-up time-out status bit (1) 1 = device is running from the external clock defined by fosc<2:0> of the configuration word 0 = device is running from the internal oscillator (hfintosc or lfintosc ) bit 2 hts: hfintosc status bit (high frequency C 8 mhz to 125 khz) 1 = hfintosc is stable 0 = hfintosc is not stable bit 1 lts: lfintosc stable bit (low frequency C 31 khz) 1 = lfintosc is stable 0 = lfintosc is not stable bit 0 scs: system clock select bit 1 = internal oscillator is used for system clock 0 = clock source defined by fosc<2:0> of the configuration word note 1: bit resets to 0 with two-speed start-up and lp, xt or hs selected as the oscillator mode or fail-safe mode is enabled. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 37 pic12f635/pic16f636/639 3.3 clock source modes clock source modes can be classified as external or internal. ? external clock modes rely on external circuitry for the clock source. examples are: oscillator mod- ules (ec mode), quartz crystal resonators or ceramic resonators (lp, xt and hs modes) and resistor-capacitor (rc) mode circuits. ? internal clock sources are contained internally within the oscillator module. the oscillator module has two internal oscillators: the 8 mhz high-frequency internal oscillator (hfintosc) and the 31 khz low-frequency internal oscillator (lfintosc). the system clock can be selected between external or internal clock sources via the system clock select (scs) bit of the osccon register. see section 3.6 clock switching for additional information. 3.4 external clock modes 3.4.1 oscillator start-up timer (ost) if the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) counts 1024 oscillations from osc1. this occurs following a power-on reset (por) and when the power-up timer (pwrt) has expired (if configured), or a wake-up from sleep. during this time, the program counter does not increment and program execution is suspended. the ost ensures that the oscillator circuit, using a quartz crystal resonator or ceramic resonator, has started and is providing a stable system clock to the oscillator module. when switching between clock sources, a delay is required to allow the new clock to stabilize. these oscillator delays are shown in table 3-1. in order to minimize latency between external oscillator start-up and code execution, the two-speed clock start-up mode can be selected (see section 3.7 two-speed clock start-up mode ). table 3-1: oscillator delay examples 3.4.2 ec mode the external clock (ec) mode allows an externally generated logic level as the system clock source. when operating in this mode, an external clock source is connected to the osc1 input and the osc2 is available for general purpose i/o. figure 3-2 shows the pin connections for ec mode. the oscillator start-up timer (ost) is disabled when ec mode is selected. therefore, there is no delay in operation after a power-on reset (por) or wake-up from sleep. because the pic ? mcu design is fully static, stopping the external clock input will have the effect of halting the device while leaving all data intact. upon restarting the external clock, the device will resume operation as if no time had elapsed. figure 3-2: external clock (ec) mode operation switch from switch to frequency oscillator delay sleep/por lfintosc hfintosc 31 khz 125 khz to 8 mhz oscillator warm-up delay (t warm ) sleep/por ec, rc dc C 20 mhz 2 instruction cycles lfintosc (31 khz) ec, rc dc C 20 mhz 1 cycle of each sleep/por lp, xt, hs 32 khz to 20 mhz 1024 clock cycles (ost) lfintosc (31 khz) hfintosc 125 khz to 8 mhz 1 s (approx.) osc1/clkin osc2/clkout (1) i/o clock from ext. system pic ? mcu note 1: alternate pin functions are listed in the section 1.0 device overview . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 38 ? 2007 microchip technology inc. 3.4.3 lp, xt, hs modes the lp, xt and hs modes support the use of quartz crystal resonators or ceramic resonators connected to osc1 and osc2 (figure 3-3). the mode selects a low, medium or high gain setting of the internal inverter-amplifier to support various resonator types and speed. lp oscillator mode selects the lowest gain setting of the internal inverter-amplifier. lp mode current con- sumption is the least of the three modes. this mode is designed to drive only 32.768 khz tuning-fork type crystals (watch crystals). xt oscillator mode selects the intermediate gain setting of the internal inverter-amplifier. xt mode current consumption is the medium of the three modes. this mode is best suited to drive resonators with a medium drive level specification. hs oscillator mode selects the highest gain setting of the internal inverter-amplifier. hs mode current consumption is the highest of the three modes. this mode is best suited for resonators that require a high drive setting. figure 3-3 and figure 3-4 show typical circuits for quartz crystal and ceramic resonators, respectively. figure 3-3: quartz crystal operation (lp, xt or hs mode) figure 3-4: ceramic resonator operation (xt or hs mode) note 1: a series resistor (r s ) may be required for quartz crystals with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . c1 c2 quartz r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu crystal osc2/clkout note 1: quartz crystal characteristics vary according to type, package and manufacturer. the user should consult the manufacturer data sheets for specifications and recommended application. 2: always verify oscillator performance over the v dd and temperature range that is expected for the application. 3: for oscillator design assistance, reference the following microchip applications notes: ? an826, crystal oscillator basics and crystal selection for rfpic ? and pic ? devices (ds00826) ? an849, basic pic ? oscillator design (ds00849) ? an943, practical pic ? oscillator analysis and design (ds00943) ? an949, making your oscillator work (ds00949) note 1: a series resistor (r s ) may be required for ceramic resonators with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . 3: an additional parallel feedback resistor (r p ) may be required for proper ceramic resonator operation. c1 c2 ceramic r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu r p (3) resonator osc2/clkout downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 39 pic12f635/pic16f636/639 3.4.4 external rc modes the external resistor-capacitor (rc) modes support the use of an external rc circuit. this allows the designer maximum flexibility in frequency choice while keeping costs to a minimum when clock accuracy is not required. there are two modes: rc and rcio. in rc mode, the rc circuit connects to osc1. osc2/clkout outputs the rc oscillator frequency divided by 4. this signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. figure 3-5 shows the external rc mode connections. figure 3-5: external rc modes in rcio mode, the rc circuit is connected to osc1. osc2 becomes an additional general purpose i/o pin. the rc oscillator frequency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values and the operating temperature. other factors affecting the oscillator frequency are: ? threshold voltage variation ? component tolerances ? packaging variations in capacitance the user also needs to take into account variation due to tolerance of external rc components used. 3.5 internal clock modes the oscillator module has two independent, internal oscillators that can be configured or selected as the system clock source. 1. the hfintosc (high-frequency internal oscillator) is factory calibrated and operates at 8 mhz. the frequency of the hfintosc can be user-adjusted via software using the osctune register (register 3-2). 2. the lfintosc (low-frequency internal oscillator) is uncalibrated and operates at 31 khz. the system clock speed can be selected via software using the internal oscillator frequency select bits ircf<2:0> of the osccon register. the system clock can be selected between external or internal clock sources via the system clock selection (scs) bit of the osccon register. see section 3.6 clock switching for more information. 3.5.1 intosc and intoscio modes the intosc and intoscio modes configure the internal oscillators as the system clock source when the device is programmed using the oscillator selection or the fosc<2:0> bits in the configuration word register (config). see section 12.0 special features of the cpu for more information. in intosc mode, osc1/clkin is available for general purpose i/o. osc2/clkout outputs the selected internal oscillator frequency divided by 4. the clkout signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. in intoscio mode, osc1/clkin and osc2/clkout are available for general purpose i/o. 3.5.2 hfintosc the high-frequency internal oscillator (hfintosc) is a factory calibrated 8 mhz internal clock source. the frequency of the hfintosc can be altered via software using the osctune register (register 3-2). the output of the hfintosc connects to a postscaler and multiplexer (see figure 3-1). one of seven frequencies can be selected via software using the ircf<2:0> bits of the osccon register. see section 3.5.4 frequency select bits (ircf) for more information. the hfintosc is enabled by selecting any frequency between 8 mhz and 125 khz by setting the ircf<2:0> bits of the osccon register 000 . then, set the system clock source (scs) bit of the osccon register to 1 or enable two-speed start-up by setting the ieso bit in the configuration word register (config) to 1 . the hf internal oscillator (hts) bit of the osccon register indicates whether the hfintosc is stable or not. osc2/clkout (1) c ext r ext pic ? mcu osc1/clkin f osc /4 or internal clock v dd v ss recommended values: 10 k r ext 100 k , <3v 3 k r ext 100 k , 3-5v c ext > 20 pf, 2-5v note 1: alternate pin functions are listed in the section 1.0 device overview . 2: output depends upon rc or rcio clock mod e. i/o (2) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 40 ? 2007 microchip technology inc. 3.5.2.1 osctune register the hfintosc is factory calibrated but can be adjusted in software by writing to the osctune register (register 3-2). the default value of the osctune register is 0 . the value is a 5-bit twos complement number. when the osctune register is modified, the hfintosc frequency will begin shifting to the new frequency. code execution continues during this shift. there is no indication that the shift has occurred. osctune does not affect the lfintosc frequency. operation of features that depend on the lfintosc clock source frequency, such as the power-up timer (pwrt), watchdog timer (wdt), fail-safe clock monitor (fscm) and peripherals, are not affected by the change in frequency. register 3-2: osctune: oscillator tuning register u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tun4 tun3 tun2 tun1 tun0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as 0 bit 4-0 tun<4:0>: frequency tuning bits 01111 = maximum frequency 01110 = ?? ? 00001 = 00000 = oscillator module is running at the calibrated frequency. 11111 = ?? ? 10000 = minimum frequency downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 41 pic12f635/pic16f636/639 3.5.3 lfintosc the low-frequency internal oscillator (lfintosc) is an uncalibrated 31 khz internal clock source. the output of the lfintosc connects to a postscaler and multiplexer (see figure 3-1). select 31 khz, via software, using the ircf<2:0> bits of the osccon register. see section 3.5.4 frequency select bits (ircf) for more information. the lfintosc is also the frequency for the power-up timer (pwrt), watchdog timer (wdt) and fail-safe clock monitor (fscm). the lfintosc is enabled by selecting 31 khz (ircf<2:0> bits of the osccon register = 000) as the system clock source (scs bit of the osccon register = 1 ), or when any of the following are enabled: ? two-speed start-up ieso bit of the configuration word register = 1 and ircf<2:0> bits of the osccon register = 000 ? power-up timer (pwrt) ? watchdog timer (wdt) ? fail-safe clock monitor (fscm) the lf internal oscillator (lts) bit of the osccon register indicates whether the lfintosc is stable or not. 3.5.4 frequency select bits (ircf) the output of the 8 mhz hfintosc and 31 khz lfintosc connects to a postscaler and multiplexer (see figure 3-1). the internal oscillator frequency select bits ircf<2:0> of the osccon register select the frequency output of the internal oscillators. one of eight frequencies can be selected via software: ?8 mhz ? 4 mhz (default after reset) ?2 mhz ?1 mhz ? 500 khz ? 250 khz ? 125 khz ? 31 khz (lfintosc) 3.5.5 hf and lf intosc clock switch timing when switching between the lfintosc and the hfintosc, the new oscillator may already be shut down to save power (see figure 3-6). if this is the case, there is a delay after the ircf<2:0> bits of the osccon register are modified before the frequency selection takes place. the lts and hts bits of the osccon register will reflect the current active status of the lfintosc and hfintosc oscillators. the timing of a frequency selection is as follows: 1. ircf<2:0> bits of the osccon register are modified. 2. if the new clock is shut down, a clock start-up delay is started. 3. clock switch circuitry waits for a falling edge of the current clock. 4. clkout is held low and the clock switch circuitry waits for a rising edge in the new clock. 5. clkout is now connected with the new clock. lts and hts bits of the osccon register are updated as required. 6. clock switch is complete. see figure 3-1 for more details. if the internal oscillator speed selected is between 8 mhz and 125 khz, there is no start-up delay before the new frequency is selected. this is because the old and new frequencies are derived from the hfintosc via the postscaler and multiplexer. start-up delay specifications are located in the a/c specifications (oscillator module) in section 15.0 electrical specifications . note: following any reset, the ircf<2:0> bits of the osccon register are set to 110 and the frequency selection is set to 4 mhz. the user can modify the ircf bits to select a different frequency. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 42 ? 2007 microchip technology inc. figure 3-6: internal oscillator switch timing hfintosc lfintosc ircf <2:0> system clock hfintosc lfintosc ircf <2:0> system clock hf lf (1) 0 = 0 0 = 0 start-up time 2-cycle sync running 2-cycle sync running hfintosc lfintosc (fscm and wdt disabled) note 1: when going from lf to hf. hfintosc lfintosc (either fscm or wdt enabled) lfintosc hfintosc ircf <2:0> system clock = 0 0 start-up time 2-cycle sync running lfintosc hfintosc lfintosc turns off unless wdt or fscm is enabled downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 43 pic12f635/pic16f636/639 3.6 clock switching the system clock source can be switched between external and internal clock sources via software using the system clock select (scs) bit of the osccon register. 3.6.1 system clock select (scs) bit the system clock select (scs) bit of the osccon register selects the system clock source that is used for the cpu and peripherals. ? when the scs bit of the osccon register = 0 , the system clock source is determined by configuration of the fosc<2:0> bits in the configuration word register (config). ? when the scs bit of the osccon register = 1 , the system clock source is chosen by the internal oscillator frequency selected by the ircf<2:0> bits of the osccon register. after a reset, the scs bit of the osccon register is always cleared. 3.6.2 oscillator start-up time-out status (osts) bit the oscillator start-up time-out status (osts) bit of the osccon register indicates whether the system clock is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register (config), or from the internal clock source. in particular, osts indicates that the oscillator start-up timer (ost) has timed out for lp, xt or hs modes. 3.7 two-speed clock start-up mode two-speed start-up mode provides additional power savings by minimizing the latency between external oscillator start-up and code execution. in applications that make heavy use of the sleep mode, two-speed start-up will remove the external oscillator start-up time from the time spent awake and can reduce the overall power consumption of the device. this mode allows the application to wake-up from sleep, perform a few instructions using the intosc as the clock source and go back to sleep without waiting for the primary oscillator to become stable. when the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) is enabled (see section 3.4.1 oscillator start-up timer (ost) ). the ost will suspend program execution until 1024 oscillations are counted. two-speed start-up mode minimizes the delay in code execution by operating from the internal oscillator as the ost is counting. when the ost count reaches 1024 and the osts bit of the osccon register is set, program execution switches to the external oscillator. 3.7.1 two-speed start-up mode configuration two-speed start-up mode is configured by the following settings: ? ieso (of the configuration word register) = 1 ; internal/external switchover bit (two-speed start-up mode enabled). ? scs (of the osccon register) = 0 . ? fosc<2:0> bits in the configuration word register (config) configured for lp, xt or hs mode. two-speed start-up mode is entered after: ? power-on reset (por) and, if enabled, after power-up timer (pwrt) has expired, or ? wake-up from sleep. if the external clock oscillator is configured to be anything other than lp, xt or hs mode, then two-speed start-up is disabled. this is because the external clock oscillator does not require any stabilization time after por or an exit from sleep. 3.7.2 two-speed start-up sequence 1. wake-up from power-on reset or sleep. 2. instructions begin execution by the internal oscillator at the frequency set in the ircf<2:0> bits of the osccon register. 3. ost enabled to count 1024 clock cycles. 4. ost timed out, wait for falling edge of the internal oscillator. 5. osts is set. 6. system clock held low until the next falling edge of new clock (lp, xt or hs mode). 7. system clock is switched to external clock source. note: any automatic clock switch, which may occur from two-speed start-up or fail-safe clock monitor, does not update the scs bit of the osccon register. the user can monitor the osts bit of the osccon register to determine the current system clock source. note: executing a sleep instruction will abort the oscillator start-up time and will cause the osts bit of the osccon register to remain clear. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 44 ? 2007 microchip technology inc. 3.7.3 checking two-speed clock status checking the state of the osts bit of the osccon register will confirm if the microcontroller is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register (config), or the internal oscillator. figure 3-7: two-speed start-up 0 1 1022 1023 pc + 1 t ost t hfintosc osc1osc2 program counter system clock pc - n pc downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 45 pic12f635/pic16f636/639 3.8 fail-safe clock monitor the fail-safe clock monitor (fscm) allows the device to continue operating should the external oscillator fail. the fscm can detect oscillator failure any time after the oscillator start-up timer (ost) has expired. the fscm is enabled by setting the fcmen bit in the configuration word register (config). the fscm is applicable to all external oscillator modes (lp, xt, hs, ec, rc and rcio). figure 3-8: fscm block diagram 3.8.1 fail-safe detection the fscm module detects a failed oscillator by comparing the external oscillator to the fscm sample clock. the sample clock is generated by dividing the lfintosc by 64. see figure 3-8. inside the fail detector block is a latch. the external clock sets the latch on each falling edge of the external clock. the sample clock clears the latch on each rising edge of the sample clock. a failure is detected when an entire half-cycle of the sample clock elapses before the primary clock goes low. 3.8.2 fail-safe operation when the external clock fails, the fscm switches the device clock to an internal clock source and sets the bit flag osfif of the pir1 register. setting this flag will generate an interrupt if the osfie bit of the pie1 register is also set. the device firmware can then take steps to mitigate the problems that may arise from a failed clock. the system clock will continue to be sourced from the internal clock source until the device firmware successfully restarts the external oscillator and switches back to external operation. the internal clock source chosen by the fscm is determined by the ircf<2:0> bits of the osccon register. this allows the internal oscillator to be configured before a failure occurs. 3.8.3 fail-safe condition clearing the fail-safe condition is cleared after a reset, executing a sleep instruction or toggling the scs bit of the osccon register. when the scs bit is toggled, the ost is restarted. while the ost is running, the device continues to operate from the intosc selected in osccon. when the ost times out, the fail-safe condition is cleared and the device will be operating from the external clock source. the fail-safe condition must be cleared before the osfif flag can be cleared. 3.8.4 reset or wake-up from sleep the fscm is designed to detect an oscillator failure after the oscillator start-up timer (ost) has expired. the ost is used after waking up from sleep and after any type of reset. the ost is not used with the ec or rc clock modes so that the fscm will be active as soon as the reset or wake-up has completed. when the fscm is enabled, the two-speed start-up is also enabled. therefore, the device will always be executing code while the ost is operating. external lfintosc 64 s r q 31 khz (~32 s) 488 hz (~2 ms) clock monitor latch clock failure detected oscillator clock q sample clock note: due to the wide range of oscillator start-up times, the fail-safe circuit is not active during oscillator start-up (i.e., after exiting reset or sleep). after an appropriate amount of time, the user should check the osts bit of the osccon register to verify the oscillator start-up and that the system clock switchover has successfully completed. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 46 ? 2007 microchip technology inc. figure 3-9: fscm timing diagram table 3-2: summary of registers associated with clock sources osfif system clock output sample clock failure detected oscillator failure note: the system clock is normally at a much higher frequency than the sample clock. the relative frequencies in this example have been chosen for clarity. (q) te s t test test clock monitor output name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) config (2) cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x osccon ircf2 ircf1 ircf0 osts hts lts scs -110 x000 -110 x000 osctune tun4 tun3 tun2 tun1 tun0 ---0 0000 ---u uuuu pie1 eeie lvdie crie c2ie (3) c1ie osfie tmr1ie 000- 00-0 000- 00-0 pir1 eeif lvdif crif c2if (3) c1if osfif tmr1if 000- 00-0 000- 00-0 legend: x = unknown, u = unchanged, ? = unimplemented locations read as 0 . shaded cells are not used by oscillators. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: see configuration word register (config) for operation of all register bits. 3: pic16f636/639 only. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 47 pic12f635/pic16f636/639 4.0 i/o ports there are as many as twelve general purpose i/o pins available. depending on which peripherals are enabled, some or all of the pins may not be available as general purpose i/o. in general, when a peripheral is enabled, the associated pin may not be used as a general purpose i/o pin. 4.1 porta and the trisa registers porta is a 6-bit wide, bidirectional port. the corresponding data direction register is trisa (register 4-2). setting a trisa bit (= 1 ) will make the corresponding porta pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisa bit (= 0 ) will make the corresponding porta pin an output (i.e., put the contents of the output latch on the selected pin). the exception is ra3, which is input only and its tris bit will always read as 1 . example 4-1 shows how to initialize porta. reading the porta register (register 4-1) reads the status of the pins, whereas writing to it will write to the port latch. all write operat ions are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. ra3 reads 0 when mclre = 1 . the trisa register controls the direction of the porta pins, even when they are being used as analog inputs. the user must ensure the bits in the trisa register are maintained set when using them as analog inputs. i/o pins configured as analog inputs always read 0 . example 4-1: initializing porta 4.2 additional pin functions every porta pin on the pic12f635/pic16f636/639 has an interrupt-on-change option and a weak pull-up/pull-down option. ra0 has an ultra low-power wake-up option. the next three sections describe these functions. 4.2.1 weak pull-up/pull-down each of the porta pins, except ra3, has an internal weak pull-up and pull-down. the wda bits select either a pull-up or pull-down for an individual port bit. individual control bits can turn on the pull-up or pull-down. these pull-ups/pull-downs are automatically turned off when the port pin is configured as an output, as an alternate function or on a power-on reset, setting the rapu bit of the option register. a weak pull-up on ra3 is enabled when configured as mclr in the configuration word register and disabled when high voltage is detected, to reduce current consumption through ra3, while in programming mode. note: porta = gpio trisa = trisio note: the cmcon0 register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read 0 . banksel porta ; clrf porta ;init porta movlw 07h ;set ra<2:0> to movwf cmcon0 ;digital i/o bsf status,rp0 ;bank 1 bcf status,rp1 ; movlw 0ch ;set ra<3:2> as inputs movwf trisa ;and set ra<5:4,1:0> ;as outputs note: porta = gpio trisa = trisio downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 48 ? 2007 microchip technology inc. register 4-1: porta: porta register u-0 u-0 r/w-x r/w-x r-x r/w-x r/w-x r/w-x ra5 ra4 ra3 ra2 ra1 ra0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-0 ra<5:0> : porta i/o pin bit 1 = port pin is > v ih 0 = port pin is < v il register 4-2: trisa: porta tri-state register u-0 u-0 r/w-1 r/w-1 r-1 r/w-1 r/w-1 r/w-1 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-0 trisa<5:0>: porta tri-state control bits 1 = porta pin configured as an input (tri-stated) 0 = porta pin configured as an output note 1: trisa<3> always reads 1 . 2: trisa<5:4> always reads 1 in xt, hs and lp oscillator modes. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 49 pic12f635/pic16f636/639 register 4-3: wda: weak pull-up/pull-down direction register u-0 u-0 r/w-1 r/w-1 u-0 r/w-1 r/w-1 r/w-1 wda5 wda4 wda2 wda1 wda0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-4 wda<5:4> : pull-up/pull-down selection bits 1 = pull-up selected 0 = pull-down selected bit 3 unimplemented : read as 0 bit 2-0 wda<2:0> : pull-up/pull-down selection bits 1 = pull-up selected 0 = pull-down selected note 1: the weak pull-up/pull-down device is enabled only when the global rapu bit is enabled, the pin is in input mode (tris = 1 ), the individual wda bit is enabled (wda = 1 ) and the pin is not configured as an analog input or clock function. 2: ra3 pull-up is enabled when the pin is configured as mclr in the configuration word register and the device is not in programming mode. register 4-4: wpuda: weak pull-up/pull-down enable register u-0 u-0 r/w-1 r/w-1 u-0 r/w-1 r/w-1 r/w-1 wpuda5 (3) wpuda4 (3) wpuda2 wpuda1 wpuda0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-4 wpuda<5:4> : pull-up/pull-down direction selection bits (3) 1 = pull-up/pull-down enabled 0 = pull-up/pull-down disabled bit 3 unimplemented : read as 0 bit 2-0 wpuda<2:0> : pull-up/pull-down direction selection bits 1 = pull-up/pull-down enabled 0 = pull-up/pull-down disabled note 1: the weak pull-up/pull-down direction device is enabled only when the global rapu bit is enabled, the pin is in input mode (tris = 1 ), the individual wpuda bit is enabled (wpuda = 1 ) and the pin is not configured as an analog input or clock function. 2: ra3 pull-up is enabled when the pin is configured as mclr in the configuration word register and the device is not in programming mode. 3: wpuda5 bit can be written if intosc is enabled and t1osc is disabled; otherwise, the bit can not be written and reads as 1 . wpuda4 bit can be written if not configured as osc2; otherwise, the bi t can not be written and reads as 1 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 50 ? 2007 microchip technology inc. 4.2.2 interrupt-on-change each of the porta pins is individually configurable as an interrupt-on-change pin. control bits, iocax, enable or disable the interrupt function for each pin. refer to register 4-5. the interrupt-on-change is disabled on a power-on reset. for enabled interrupt-on-change pins, the values are compared with the old value latched on the last read of porta. the mismatch outputs of the last read are ord together to set the porta change interrupt flag bit (raif) in the intcon register. this interrupt can wake the device from sleep. the user, in the interrupt service routine, clears the interrupt by: a) any read or write of porta. this will end the mismatch condition, then b) clear the flag bit raif. a mismatch condition will continue to set flag bit raif. reading porta will end the mismatch condition and allow flag bit raif to be cleared. the latch holding the last read value is not affected by a mclr nor bor reset. after these resets, the raif flag will continue to be set if a mismatch is present. note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the raif interrupt flag may not get set. register 4-5: ioca: interrupt-on-change porta register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 i o c a 5 (2) ioca4 (2) ioca3 (3) ioca2 ioca1 ioca0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-0 ioca<5:0>: interrupt-on-change porta control bits (2,3) 1 = interrupt-on-change enabled (1) 0 = interrupt-on-change disabled note 1: global interrupt enable (gie) must be enabled for individual interrupts to be recognized. 2: ioca<5:4> always reads 0 in xt, hs and lp oscillator modes. 3: ioca<3> is ignored when wur is enabled and the device is in sleep mode. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 51 pic12f635/pic16f636/639 4.2.3 ultra low-power wake-up the ultra low-power wake-up (ulpwu) on ra0 allows a slow falling voltage to generate an interrupt-on-change on ra0 without excess current consumption. the mode is selected by setting the ulpwue bit of the pcon register. this enables a small current sink which can be used to discharge a capacitor on ra0. to use this feature, the ra0 pin is configured to output 1 to charge the capacitor, interrupt-on-change for ra0 is enabled and ra0 is configured as an input. the ulpwue bit is set to begin the discharge and a sleep instruction is performed. when the voltage on ra0 drops below v il , an interrupt will be generated which will cause the device to wake-up. depending on the state of the gie bit of the intcon register, the device will either jump to the interrupt vector (0004h) or execute the next instruction when the interrupt event occurs. see section 4.2.2 interrupt-on-change and section 12.9.3 porta interrupt for more information. this feature provides a low-power technique for periodically waking up the device from sleep. the time-out is dependent on the discharge time of the rc circuit on ra0. see example 4-2 for initializing the ultra low power wake-up module. the series resistor provides overcurrent protection for the ra0 pin and can allow for software calibration of the time-out (see figure 4-1). a timer can be used to measure the charge time and discharge time of the capacitor. the charge time can then be adjusted to provide the desired interrupt delay. this technique will compensate for the affects of temperature, voltage and component accuracy. the ultra low-power wake-up peripheral can also be configured as a simple programmable low-voltage detect or temperature sensor. example 4-2: ultra low-power wake-up initialization note: for more information, refer to the application note an879, using the microchip ultra low-power wake-up module (ds00879). banksel porta ; bsf porta,0 ;set ra0 data latch movlw h?7? ;turn off movwf cmcon0 ; comparators banksel trisa ; bcf trisa,0 ;output high to call capdelay ; charge capacitor bsf pcon,ulpwue ;enable ulp wake-up bsf ioca,0 ;select ra0 ioc bsf trisa,0 ;ra0 to input movlw b?10001000? ;enable interrupt movwf intcon ; and clear flag sleep ;wait for ioc nop ; downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 52 ? 2007 microchip technology inc. 4.2.4 pin descriptions and diagrams each porta pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions, such as the comparator, refer to the appropriate section in this data sheet. 4.2.4.1 ra0/c1in+/icspdat/ulpwu figure 4-2 shows the diagram for this pin. the ra0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input to the comparator ? in-circuit serial programming? data ? an analog input for the ultra low-power wake-up figure 4-1: block diagram of ra0 i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak rd porta rd wrwr rd wr ioca rd ioca interrupt-on- analog input mode (1) change q1 wr rd 01 i ulp wpuda data bus wpuda porta trisa trisa porta note 1: comparator mode determines analog input mode. v t ulpwue C + v ss d q ck q wr rd wdawda analog input mode (1) rapu weak downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 53 pic12f635/pic16f636/639 4.2.4.2 ra1/c1in-/v ref /icspclk figure 4-2 shows the diagram for this pin. the ra1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input to the comparator ? in-circuit serial programming? clock figure 4-2: block diagram of ra1 4.2.4.3 ra2/t0cki/int/c1out figure 4-3 shows the diagram for this pin. the ra2 pin is configurable to function as one of the following: ? a general purpose i/o ? the clock input for timer0 ? an external edge-triggered interrupt ? a digital output from the comparator figure 4-3: block diagram of ra2 i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q d en q d en q data bus wr wpuda rd wpuda rd porta rd porta wr porta wr trisa rd trisa wr ioca rd ioca interrupt-on- to comparator rapu analog input mode (1) change d q ck q wr wda rd wda v dd weak weak v ss analog input mode (1) q1 note 1: comparator mode determines analog input mode. i/o pin v dd v ss d q ck q d q ck q d q ck q d en q d en q rd porta wr porta wr trisa rd trisa wr ioca rd ioca 0 1 c1out to i n t to timer0 rd porta interrupt-on- change d q ck q data bus wr wpuda rd wpuda rapu d q ck q wr wda rd wda v dd weak weak v ss c1out enable q1 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 54 ? 2007 microchip technology inc. 4.2.4.4 ra3/mclr /v pp figure 4-4 shows the diagram for this pin. the ra3 pin is configurable to function as one of the following: ? a general purpose input ? as master clear reset with weak pull-up ? a high-voltage detect for program mode entry figure 4-4: block diagram of ra3 input v ss d q ck q d en q data bus rd porta rd porta wr ioca rd ioca reset mclre rd trisa v ss d en q mclre v dd weak mclre interrupt-on- change pin hv detect program mode q1 wure sleep downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 55 pic12f635/pic16f636/639 4.2.4.5 ra4/t1g /osc2/clkout figure 4-5 shows the diagram for this pin. the ra4 pin is configurable to function as one of the following: ? a general purpose i/o ? a timer1 gate input ? a crystal/resonator connection ? a clock output figure 4-5: block diagram of ra4 4.2.4.6 ra5/t1cki/osc1/clkin figure 4-6 shows the diagram for this pin. the ra5 pin is configurable to function as one of the following: ? a general purpose i/o ? a timer1 clock input ? a crystal/resonator connection ? a clock input figure 4-6: block diagram of ra5 i/o pi n v dd v ss d q ck q d q ck q d q ck q d en q d en q xtal rd porta wr porta wr trisa rd trisa wr ioca rd ioca f osc /4 oscillator circuit osc1 clkout 0 1 clkout enable enable rd porta t 1g to ti m e r 1 intosc/ rc/ec (2) clkout enable note 1: oscillator modes are xt, hs, lp, lptmr1 and clkout enable. 2: with clkout option. interrupt-on- change d q ck q data bus wr wpuda rd wpuda rapu d q ck q wr wda rd wda v dd weak weak v ss clk (1) modes q1 i/o pin v dd v ss d q ck q d q ck q d q ck q d en q d en q rd porta wr porta wr trisa rd trisa wr ioca rd ioca t1g to timer1 intosc mode rd porta osc2 (2) note 1: oscillator modes are xt, hs, lp and lptmr1. 2: when using timer1 with lp oscillator, the schmitt trigger is bypassed. interrupt-on- change oscillator circuit d q ck q data bus wr wpuda rd wpuda rapu d q ck q wr wda rd wda v dd weak weak v ss clk (1) modes q1 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 56 ? 2007 microchip technology inc. table 4-1: summary of registers associated with porta name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor, wur value on all other resets porta ra5 ra4 ra3 ra2 ra1 ra0 --xx xx00 --uu uu00 intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu cmcon1 t 1 g s s cxsync ---- --10 ---- --10 cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 option_reg rapu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 trisa trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 --11 1111 --11 1111 wpuda wpuda5 wpuda4 wpuda2 wpuda1 wpuda0 --11 -111 --11 -111 ioca ioca5 ioca4 ioca3 ioca2 ioca1 ioca0 --00 0000 --00 0000 wda wda5 wda4 wda2 wda1 wda0 --11 -111 --11 -111 legend: x = unknown, u = unchanged, C = unimplemented locations read as 0 . shaded cells are not used by porta. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 57 pic12f635/pic16f636/639 4.3 portc portc is a general purpose i/o port consisting of 6 bidirectional pins. the pins can be configured for either digital i/o or analog input to comparator. for specific information about individual functions, refer to the appropriate section in this data sheet. example 4-3: initializing portc note: the cmcon0 register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read 0 . banksel portc ; clrf portc ;init portc movlw 07h ;set rc<4,1:0> to movwf cmcon0 ;digital i/o banksel trisc ; movlw 0ch ;set rc<3:2> as inputs movwf trisc ;and set rc<5:4,1:0> ;as outputs register 4-6: portc: portc register u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-0 r/w-0 rc5 rc4 rc3 rc2 rc1 rc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-0 rc<5:0>: portc general purpose i/o pin bits 1 = port pin is > v ih 0 = port pin is < v il register 4-7: trisc: portc tri-state register u-0 u-0 r/w-1 r/w-1 r-1 r/w-1 r/w-1 r/w-1 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented : read as 0 bit 5-0 trisc<5:0>: portc tri-state control bits 1 = portc pin configured as an input (tri-stated) 0 = portc pin configured as an output downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 58 ? 2007 microchip technology inc. 4.3.1 rc0/c2in+ figure 4-7 shows the diagram for this pin. the rc0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input to the comparator 4.3.2 rc1/c2in- figure 4-7 shows the diagram for this pin. the rc1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input to the comparator 4.3.3 rc2 figure 4-8 shows the diagram for this pin. the rc2 pin is configurable to function as a general purpose i/o. 4.3.4 rc3 figure 4-8 shows the diagram for this pin. the rc3 pin is configurable to function as a general purpose i/o. 4.3.5 rc5 figure 4-8 shows the diagram for this pin. the rc5 pin is configurable to function as a general purpose i/o. figure 4-7: block diagram of rc0 and rc1 figure 4-8: block diagram of rc2, rc3 and rc5 i/o pin v dd v ss d q ck q d q ck q data bus wr portc wr trisc rd trisc rd portc analog input mode to comparators i/o pin v dd v ss d q ck q d q ck q data bus wr portc wr trisc rd trisc rd portc downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 59 pic12f635/pic16f636/639 4.3.6 rc4/c2out figure 4-9 shows the diagram for this pin. the rc4 pin is configurable to function as one of the following: ? a general purpose i/o ? a digital output from the comparator figure 4-9: block diagram of rc4 table 4-2: summary of registers associated with portc i/o pin v dd v ss d q ck q d q ck q data bus wr portc wr trisc rd trisc rd portc 0 1 c2out enable c2out name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor, wur value on all other resets portc rc5 rc4 rc3 rc2 rc1 rc0 --xx xx00 --uu uu00 cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 trisc trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 --11 1111 --11 1111 legend: x = unknown, u = unchanged, C = unimplemented locations read as 0 . shaded cells are not used by porta. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 60 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 61 pic12f635/pic16f636/639 5.0 timer0 module the timer0 module is an 8-bit timer/counter with the following features: ? 8-bit timer/counter register (tmr0) ? 8-bit prescaler (shared with watchdog timer) ? programmable internal or external clock source ? programmable external clock edge selection ? interrupt on overflow figure 5-1 is a block diagram of the timer0 module. 5.1 timer0 operation when used as a timer, the timer0 module can be used as either an 8-bit timer or an 8-bit counter. 5.1.1 8-bit timer mode when used as a timer, the timer0 module will increment every instruction cycle (without prescaler). timer mode is selected by clearing the t0cs bit of the option register to 0 . when tmr0 is written, the increment is inhibited for two instruction cycles immediately following the write. 5.1.2 8-bit counter mode when used as a counter, the timer0 module will increment on every rising or falling edge of the t0cki pin. the incrementing edge is determined by the t0se bit of the option register. counter mode is selected by setting the t0cs bit of the option register to 1 . figure 5-1: block diagram of the timer0/wdt prescaler note: the value written to the tmr0 register can be adjusted, in order to account for the two instruction cycle delay when tmr0 is written. t0cki t0se pin tmr0 watchdog timer wdt time-out ps<2:0> wdte data bus set flag bit t0if on overflow t0cs note 1: t0se, t0cs, psa, ps<2:0> are bits in the option register. 2: swdten and wdtps<3:0> are bits in the wdtcon register. 3: wdte bit is in the configuration word register. 01 0 1 01 8 8 8-bit prescaler 0 1 f osc /4 psa psa psa 16-bit prescaler 16 wdtps<3:0> 31 khz intosc swdten sync 2 t cy downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 62 ? 2007 microchip technology inc. 5.1.3 software programmable prescaler a single software programmable prescaler is available for use with either timer0 or the watchdog timer (wdt), but not both simultaneously. the prescaler assignment is controlled by the psa bit of the option register. to assign the prescaler to timer0, the psa bit must be cleared to a 0 . there are 8 prescaler options for the timer0 module ranging from 1:2 to 1:256. the prescale values are selectable via the ps<2:0> bits of the option register. in order to have a 1:1 prescaler value for the timer0 module, the prescaler must be assigned to the wdt module. the prescaler is not readable or writable. when assigned to the timer0 module, all instructions writing to the tmr0 register will clear the prescaler. when the prescaler is assigned to wdt, a clrwdt instruction will clear the prescaler along with the wdt. 5.1.3.1 switching prescaler between timer0 and wdt modules as a result of having the prescaler assigned to either timer0 or the wdt, it is possible to generate an unintended device reset when switching prescaler values. when changing the prescaler assignment from timer0 to the wdt module, the instruction sequence shown in example 5-1, must be executed. example 5-1: changing prescaler (timer0 wdt) when changing the prescaler assignment from the wdt to the timer0 module, the following instruction sequence must be executed (see example 5-2). example 5-2: changing prescaler (wdt timer0) 5.1.4 timer0 interrupt timer0 will generate an interrupt when the tmr0 register overflows from ffh to 00h. the t0if interrupt flag bit of the intcon register is set every time the tmr0 register overflows, regardless of whether or not the timer0 interrupt is enabled. the t0if bit must be cleared in software. the timer0 interrupt enable is the t0ie bit of the intcon register.. 5.1.5 using timer0 with an external clock when timer0 is in counter mode, the synchronization of the t0cki input and the timer0 register is accom- plished by sampling the prescaler output on the q2 and q4 cycles of the internal phase clocks. therefore, the high and low periods of the external clock source must meet the timing requirements as shown in the section 15.0 electrical specifications . banksel tmr0 ; clrwdt ;clear wdt clrf tmr0 ;clear tmr0 and ;prescaler banksel option_reg ; bsf option_reg,psa ;select wdt clrwdt ; ; movlw b?11111000? ;mask prescaler andwf option_reg,w ;bits iorlw b?00000101? ;set wdt prescaler movwf option_reg ;to 1:32 note: the timer0 interrupt cannot wake the processor from sleep since the timer is frozen during sleep. clrwdt ;clear wdt and ;prescaler banksel option_reg ; movlw b?11110000? ;mask tmr0 select and andwf option_reg,w ;prescaler bits iorlw b?00000011? ;set prescale to 1:16 movwf option_reg ; downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 63 pic12f635/pic16f636/639 table 5-1: summary of registers associated with timer0 register 5-1: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 rapu intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 r apu : porta pull-up enable bit 1 = porta pull-ups are disabled 0 = porta pull-ups are enabled by individual port latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of int pin 0 = interrupt on falling edge of int pin bit 5 t0cs: tmr0 clock source select bit 1 = transition on t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: tmr0 source edge select bit 1 = increment on high-to-low transition on t0cki pin 0 = increment on low-to-high transition on t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits note 1: a dedicated 16-bit wdt postscaler is available. see section 12.11 watchdog timer (wdt) for more information. 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value tmr0 rate wdt rate name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets tmr0 timer0 module register xxxx xxxx uuuu uuuu intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x option_reg rapu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 trisa trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 --11 1111 --11 1111 legend: C = unimplemented locations, read as 0 , u = unchanged, x = unknown. shaded cells are not used by the timer0 module. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 64 ? 2007 microchip technology inc. 6.0 timer1 module with gate control the timer1 module is a 16-bit timer/counter with the following features: ? 16-bit timer/counter register pair (tmr1h:tmr1l) ? programmable internal or external clock source ? 3-bit prescaler ? optional lp oscillator ? synchronous or asynchronous operation ? timer1 gate (count enable) via comparator or t1g pin ? interrupt on overflow ? wake-up on overflow (external clock, asynchronous mode only) ? comparator output synchronization to timer1 clock figure 6-1 is a block diagram of the timer1 module. 6.1 timer1 operation the timer1 module is a 16-bit incrementing counter which is accessed through the tmr1h:tmr1l register pair. writes to tmr1h or tmr1l directly update the counter. when used with an internal clock source, the module is a timer. when used with an external clock source, the module can be used as either a timer or counter. 6.2 clock source selection the tmr1cs bit of the t1con register is used to select the clock source. when tmr1cs = 0 , the clock source is f osc /4. when tmr1cs = 1 , the clock source is supplied externally. clock source t1oscen fosc mode t1cs f osc /4 x xxx x t1cki pin x1 t1lposc 1 lp or intoscio downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 65 pic12f635/pic16f636/639 figure 6-1: timer1 block diagram tmr1h tmr1l oscillator t1sync t1ckps<1:0> f osc /4 internal clock prescaler 1, 2, 4, 8 1 0 01 synchronized clock input 2 set flag bit tmr1if on overflow tmr1 (2) tmr1ge tmr1on t1oscen 10 cxout t1gss t1ginv to c2 comparator module timer1 clock tmr1cs osc2/t1g osc1/t1cki note 1: st buffer is low power type when using lp osc, or high speed type when using t1cki. 2: timer1 register increments on rising edge. 3: synchronize does not operate while in sleep. (1) en intosc without clkout 10 t1acs f osc synchronize (3) det downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 66 ? 2007 microchip technology inc. 6.2.1 internal clock source when the internal clock source is selected the tmr1h:tmr1l register pair will increment on multiples of t cy as determined by the timer1 prescaler. 6.2.2 external clock source when the external clock source is selected, the timer1 module may work as a timer or a counter. when counting, timer1 is incremented on the rising edge of the external clock input t1cki. in addition, the counter mode clock can be synchronized to the microcontroller system clock or run asynchronously. in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge after one or more of the following conditions: ? timer1 is enabled after por or bor reset ? a write to tmr1h or tmr1l ? t1cki is high when timer1 is disabled and when timer1 is reenabled t1cki is low. see figure 6-2. 6.3 timer1 prescaler timer1 has four prescaler options allowing 1, 2, 4 or 8 divisions of the clock input. the t1ckps bits of the t1con register control the prescale counter. the prescale counter is not directly readable or writable; however, the prescaler counter is cleared upon a write to tmr1h or tmr1l. 6.4 timer1 oscillator a low-power 32.768 khz crystal oscillator is built-in between pins osc1 (input) and osc2 (amplifier out- put). the oscillator is enabled by setting the t1oscen control bit of the t1con register. the oscillator will continue to run during sleep. the timer1 oscillator is shared with the system lp oscillator. thus, timer1 can use this mode only when the primary system clock is derived from the internal oscillator or when in lp oscillator mode. the user must provide a software time delay to ensure proper oscilla- tor start-up. trisa5 and trisa4 bits are set when the timer1 oscillator is enabled. ra5 and ra4 bits read as 0 and trisa5 and trisa4 bits read as 1 . 6.5 timer1 operation in asynchronous counter mode if control bit t1sync of the t1con register is set, the external clock input is not synchronized. the timer continues to increment asynchronous to the internal phase clocks. the timer will continue to run during sleep and can generate an interrupt on overflow, which will wake-up the processor. however, special precautions in software are needed to read/write the timer (see section 6.5.1 reading and writing timer1 in asynchronous counter mode ). 6.5.1 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running from an external asynchronous clock will ensure a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself, poses certain problems, since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write contention may occur by writing to the timer registers, while the register is incrementing. this may produce an unpredictable value in the tmr1h:ttmr1l register pair. 6.6 timer1 gate timer1 gate source is software configurable to be the t1g pin or the output of comparator 2. this allows the device to directly time external events using t1g or analog events using comparator 2. see the cmcon1 register (register 7-3) for selecting the timer1 gate source. this feature can simplify the software for a delta-sigma a/d converter and many other applications. for more information on delta-sigma a/d converters, see the microchip web site (www.microchip.com). timer1 gate can be inverted using the t1ginv bit of the t1con register, whether it originates from the t1g pin or comparator 2 output. this configures timer1 to measure either the active-high or active-low time between events. note: the oscillator requires a start-up and stabilization time before use. thus, t1oscen should be set and a suitable delay observed prior to enabling timer1. note: when switching from synchronous to asynchronous operation, it is possible to skip an increment. when switching from asynchronous to synchronous operation, it is possible to produce a single spurious increment. note: tmr1ge bit of the t1con register must be set to use either t1g or c2out as the timer1 gate source. see register 7-3 for more information on selecting the timer1 gate source. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 67 pic12f635/pic16f636/639 6.7 timer1 interrupt the timer1 register pair (tmr1h:tmr1l) increments to ffffh and rolls over to 0000h. when timer1 rolls over, the timer1 interrupt flag bit of the pir1 register is set. to enable the interrupt on rollover, you must set these bits: ? timer1 interrupt enable bit of the pie1 register ? peie bit of the intcon register ? gie bit of the intcon register the interrupt is cleared by clearing the tmr1if bit in the interrupt service routine. 6.8 timer1 operation during sleep timer1 can only operate during sleep when setup in asynchronous counter mode. in this mode, an external crystal or clock source can be used to increment the counter. to set up the timer to wake the device: ? tmr1on bit of the t1con register must be set ? tmr1ie bit of the pie1 register must be set ? peie bit of the intcon register must be set the device will wake-up on an overflow and execute the next instruction. if the gie bit of the intcon register is set, the device will call the interrupt service routine (0004h). 6.9 comparator synchronization the same clock used to increment timer1 can also be used to synchronize the comparator output. this feature is enabled in the comparator module. when using the comparator for timer1 gate, the comparator output should be synchronized to timer1. this ensures timer1 does not miss an increment if the comparator changes. for more information, see section 7.0 comparator module . figure 6-2: timer1 incrementing edge note: the tmr1h:ttmr1l register pair and the tmr1if bit should be cleared before enabling interrupts. t1cki = 1 when tmr1 enabled t1cki = 0 when tmr1 enabled note 1: arrows indicate counter increments. 2: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge of the clock. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 68 ? 2007 microchip technology inc. 6.10 timer1 control register the timer1 control register (t1con), shown in register 6-1, is used to control timer1 and select the various features of the timer1 module. register 6-1: t1con: ti mer 1 control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 t1ginv (1) tmr1ge (2) t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 t1ginv: timer1 gate invert bit (1) 1 = timer1 gate is active-high (timer1 counts when gate is high) 0 = timer1 gate is active-low (timer1 counts when gate is low) bit 6 tmr1ge: timer1 gate enable bit (2) if tmr1on = 0 : this bit is ignored if tmr1on = 1 : 1 = timer1 is on if timer1 gate is active 0 = timer1 is on bit 5-4 t1ckps<1:0>: timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3 t1oscen: lp oscillator enable control bit if intosc without clkout oscillator is active: 1 = lp oscillator is enabled for timer1 clock 0 = lp oscillator is off else: this bit is ignored. lp oscillator is disabled. bit 2 t1sync : timer1 external clock input synchronization control bit tmr1cs = 1 : 1 = do not synchronize external clock input 0 = synchronize external clock input tmr1cs = 0 : this bit is ignored. timer1 uses the internal clock bit 1 tmr1cs: timer1 clock source select bit 1 = external clock from t1cki pin (on the rising edge) 0 = internal clock (f osc /4) bit 0 tmr1on: timer1 on bit 1 = enables timer1 0 = stops timer1 note 1: t1ginv bit inverts the timer1 gate logic, regardless of source. 2: tmr1ge bit must be set to use either t1g pin or c2out, as selected by the t1gss bit of the cmcon1 register, as a timer1 gate source. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 69 pic12f635/pic16f636/639 table 6-1: summary of registers associated with timer1 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets cmcon1 t1gss cmsync ---- --10 00-- --10 intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x pie1 eeie lvdie crie c2ie (1) c1ie osfie t m r 1 i e 000- 00-0 000- 00-0 pir1 eeif lvdif crif c2if (1) c1if osfif t m r 1 i f 000- 00-0 000- 00-0 tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu legend: x = unknown, u = unchanged, ? = unimplemented, read as 0 . shaded cells are not used by the timer1 module. note 1: pic16f636/639 only. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 70 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 71 pic12f635/pic16f636/639 7.0 comparator module comparators are used to interface analog circuits to a digital circuit by comparing two analog voltages and providing a digital indication of their relative magnitudes. the comparators are very useful mixed signal building blocks because they provide analog functionality independent of the program execution. the analog comparator module includes the following features: ? dual comparators (pic16f636/639 only) ? multiple comparator configurations ? comparator(s) output is available internally/externally ? programmable output polarity ? interrupt-on-change ? wake-up from sleep ? timer1 gate (count enable) ? output synchronization to timer1 clock input ? programmable voltage reference 7.1 comparator overview a comparator is shown in figure 7-1 along with the relationship between the analog input levels and the digital output. when the analog voltage at v in + is less than the analog voltage at v in -, the output of the comparator is a digital low level. when the analog voltage at v in + is greater than the analog voltage at v in -, the output of the comparator is a digital high level. the pic12f635 contains a single comparator as shown in figure 7-2. the pic16f636/639 devices contains two comparators as shown in figure 7-3 and figure 7-4. the comparators are not independently configurable. figure 7-1: single comparator figure 7-2: comparator output block diagram (pic12f635) C + v in + v in - output output v in + v in - note: the black areas of the output of the comparator represents the uncertainty due to input offsets and response time. cmsync dq en to cout pin rd cmcon0 set cmif bit multiplex port pins q3*rd cmcon0 reset to data bus cinv timer1 clock source (1) 01 to timer1 gate note 1: comparator output is latched on fa lling edge of timer1 clock source. 2: q1 and q3 are phases of the four-phase system clock (f osc ). 3: q1 is held high during sleep mode. dq dq en cl q1 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 72 ? 2007 microchip technology inc. figure 7-3: comparator c1 output block diagram (pic16f636/639) figure 7-4: comparator c2 output block diagram (pic16f636/639) dq en to c1out pin rd cmcon0 set c1if bit multiplex port pins q3*rd cmcon0 reset to d a ta b u s c1inv dq en cl q1 note 1: q1 and q3 are phases of the four-phase system clock (f osc ). 2: q1 is held high during sleep mode. c1 c2sync dq en to c2out pin rd cmcon0 set c2if bit multiplex port pins q3*rd cmcon0 reset to data bus c2inv timer1 clock source (1) 01 to timer1 gate dq dq en cl q1 note 1: comparator output is latched on fa lling edge of timer1 clock source. 2: q1 and q3 are phases of the four-phase system clock (f osc ). 3: q1 is held high during sleep mode. c2 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 73 pic12f635/pic16f636/639 7.2 analog input connection considerations a simplified circuit for an analog input is shown in figure 7-5. since the analog input pins share their con- nection with a digital input, they have reverse biased esd protection diodes to v dd and v ss . the analog input, therefore, must be between v ss and v dd . if the input voltage deviates from this range by more than 0.6v in either direction, one of the diodes is forward biased and a latch-up may occur. a maximum source impedance of 10 k is recommended for the analog sources. also, any external component connected to an analog input pin, such as a capacitor or a zener diode, should have very little leakage current to minimize inaccuracies introduced. figure 7-5: analog input model note 1: when reading a port register, all pins configured as analog inputs will read as a 0 . pins configured as digital inputs will convert as an analog input, according to the input specification. 2: analog levels on any pin defined as a digital input, may cause the input buffer to consume more current than is specified. v a rs < 10k c pin 5 pf v dd v t 0.6v v t 0.6v r ic i leakage 500 na vss a in legend: c pin = input capacitance i leakage = leakage current at the pin due to various junctions r ic = interconnect resistance r s = source impedance v a = analog voltage v t = threshold voltage to comparator downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 74 ? 2007 microchip technology inc. 7.3 comparator configuration there are eight modes of operation for the comparator. the cm<2:0> bits of the cmcon0 register are used to select these modes as shown in figures 7-6 and 7-7. i/o lines change as a function of the mode and are designed as follows: ? analog function (a): digital input buffer is disabled ? digital function (d): comparator digital output, overrides port function ? normal port function (i/o): independent of comparator the port pins denoted as a will read as a 0 regardless of the state of the i/o pin or the i/o control tris bit. pins used as analog inputs should also have the corresponding tris bit set to 1 to disable the digital output driver. pins denoted as d should have the corresponding tris bit set to 0 to enable the digital output driver. figure 7-6: comparator i/o operating modes (pic12f635) note: comparator interrupts should be disabled during a comparator mode change to prevent unintended interrupts. comparator reset (por default value C low power) comparator w/o output and with internal reference cm<2:0> = 000 cm<2:0> = 100 comparator with output multiplexed input with internal reference and output cm<2:0> = 001 cm<2:0> = 101 comparator without output multiplexed input with internal reference cm<2:0> = 010 cm<2:0> = 110 comparator with output and internal reference comparator off (lowest power) cm<2:0> = 011 cm<2:0> = 111 legend: a = analog input, ports always reads 0 cis = comparator input switch (cmcon0<3>) i/o = normal port i/o d = comparator digital output note 1: reads as 0 , unless cinv = 1 . cin-cin+ off (1) aa cout (pin) i/o cin-cin+ cout ai/o cout (pin) i/o from cv ref module cin-cin+ cout aa cout (pin) d cin-cin+ cout aa cout (pin) d from cv ref module cis = 0 cis = 1 cin-cin+ cout aa cout (pin) i/o cin- cin+ cout aa cout (pin) i/o from cv ref module cis = 0 cis = 1 cin-cin+ cout a i/o cout (pin) d from cv ref module cin- cin+ off (1) i/oi/o cout (pin) i/o downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 75 pic12f635/pic16f636/639 figure 7-7: comparator i/o operating modes (pic16f636/639) c1 c1in- v in - v in + c1in+ off (1) comparators reset (por default value) aa cm<2:0> = 000 c2 c2in- v in - v in + c2in+ off (1) aa c1 c1in- v in - v in + c1in+ c1out two independent comparators aa cm<2:0> = 100 c2 c2in- v in - v in + c2in+ c2out aa c1 c1in- v in - v in + c1in+ c1out two common reference comparators a i/o cm<2:0> = 011 c2 c2in- v in - v in + c2in+ c2out aa c1 c1in- v in - v in + c1in+ off (1) one independent comparator i/oi/o cm<2:0> = 101 c2 c2in- v in - v in + c2in+ c2out aa c1 c1in- v in - v in + c1in+ off (1) comparators off (lowest power) i/oi/o cm<2:0> = 111 c2 c2in- v in - v in + c2in+ off (1) i/oi/o c1 c1in- v in - v in + c1in+ c1out four inputs multiplexed to two comparators aa cm<2:0> = 010 c2 c2in- v in - v in + c2in+ c2out aa from cv ref module cis = 0 cis = 1 cis = 0 cis = 1 c1 c1in- v in - v in + c1out(pin) c1out two common reference comparators with outputs ad cm<2:0> = 110 c2 c2in- v in - v in + c2in+ c2out aa c2out(pin) c1 c1in- v in - v in + c1in+ c1out three inputs multiplexed to two comparators aa cm<2:0> = 001 c2 c2in- v in - v in + c2in+ c2out aa cis = 0 cis = 1 d legend: a = analog input, ports always reads 0 cis = comparator input switch (cmcon0<3>) i/o = normal port i/o d = comparator digital output note 1: reads as 0 , unless cxinv = 1 . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 76 ? 2007 microchip technology inc. 7.4 comparator control the cmcon0 register (register 7-1) provides access to the following comparator features: ? mode selection ? output state ? output polarity ? input switch 7.4.1 comparator output state each comparator state can always be read internally via the cxout bit of the cmcon0 register. the com- parator state may also be directed to the cxout pin in the following modes: pic12f635 ? cm<2:0> = 001 ? cm<2:0> = 011 ? cm<2:0> = 101 pic16f636/639 ? cm<2:0> = 110 when one of the above modes is selected, the associated tris bit of the cxout pin must be cleared. 7.4.2 comparator output polarity inverting the output of a comparator is functionally equivalent to swapping the comparator inputs. the polarity of a comparator output can be inverted by set- ting the c x inv bit of the cmcon0 register. clearing c x inv results in a non-inverted output. a complete table showing the output state versus input conditions and the polarity bit is shown in table 7-1. table 7-1: output state vs. input conditions 7.4.3 comparator input switch the inverting input of the comparators may be switched between two analog pins in the following modes: pic12f635 ?cm<2:0> = 101 ?cm<2:0> = 110 pic16f636/639 ?cm<2:0> = 001 (comparator c1 only) ?cm<2:0> = 010 (comparators c1 and c2) in the above modes, both pins remain in analog mode regardless of which pin is selected as the input. the cis bit of the cmcon0 register controls the comparator input switch. input conditions cxinv cxout v in - > v in + 00 v in - < v in + 01 v in - > v in + 11 v in - < v in + 10 note: cxout refers to both the register bit and output pin. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 77 pic12f635/pic16f636/639 7.5 comparator response time the comparator output is indeterminate for a period of time after the change of an input source or the selection of a new reference voltage. this period is referred to as the response time. the response time of the comparator differs from the settling time of the voltage reference. therefore, both of these times must be considered when determining the total response time to a comparator input change. see the comparator and voltage specifications in section 15.0 electrical specifications for more details. 7.6 comparator interrupt operation the comparator interrupt flag is set whenever there is a change in the output value of the comparator. changes are recognized by means of a mismatch circuit which consists of two latches and an exclusive-or gate (see figures 7-8 and 7-9). one latch is updated with the comparator output level when the cmcon0 register is read. this latch retains the value until the next read of the cmcon0 register or the occurrence of a reset. the other latch of the mismatch circuit is updated on every q1 system clock. a mismatch condition will occur when a comparator output change is clocked through the second latch on the q1 clock cycle. the mismatch condition will persist, holding the cxif bit of the pir1 register true, until either the cmcon0 register is read or the comparator output returns to the previous state. software will need to maintain information about the status of the comparator output to determine the actual change that has occurred. the cxif bit of the pir1 register, is the comparator interrupt flag. this bit must be reset in software by clearing it to 0 . since it is also possible to write a 1 to this register, a simulated interrupt may be initiated. the cxie bit of the pie1 register and the peie and gie bits of the intcon register must all be set to enable comparator interrupts. if any of these bits are cleared, the interrupt is not enabled, although the cxif bit of the pir1 register will still be set if an interrupt condition occurs. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of cmcon0. this will end the mismatch condition. see figures 7-8 and 7-9. b) clear the cxif interrupt flag. a persistent mismatch condition will preclude clearing the cxif interrupt flag. reading cmcon0 will end the mismatch condition and allow the cxif bit to be cleared. note: a write operation to the cmcon0 register will also clear the mismatch condition because all writes include a read operation at the beginning of the write cycle. note: if a change in the cmcon0 register (cxout) should occur when a read operation is being executed (start of the q2 cycle), then the cxif interrupt flag may not get set. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 78 ? 2007 microchip technology inc. figure 7-8: comparator interrupt timing w/o cmcon0 read figure 7-9: comparator interrupt timing with cmcon0 read note 1: if a change in the cmcon0 register (cxout) should occur when a read operation is being executed (start of the q2 cycle), then the cxif of the pir1 register interrupt flag may not get set. 2: when either comparator is first enabled, bias circuitry in the comparator module may cause an invalid output from the comparator until the bias circuitry is stable. allow about 1 s for bias settling then clear the mismatch condition and interrupt flags before enabling comparator interrupts. q1q3 c in + cxout set cxif (level) cxif t rt reset by software q1q3 c in + cxout set cxif (level) cxif t rt reset by software cleared by cmcon0 read downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 79 pic12f635/pic16f636/639 7.7 operation during sleep the comparator, if enabled before entering sleep mode, remains active during sleep. the additional current consumed by the comparator is shown separately in the section 15.0 electrical specifications . if the comparator is not used to wake the device, power consumption can be minimized while in sleep mode by turning off the comparator. the comparator is turned off by selecting mode cm<2:0> = 000 or cm<2:0> = 111 of the cmcon0 register. a change to the comparator output can wake-up the device from sleep. to enable the comparator to wake the device from sleep, the cxie bit of the pie1 register and the peie bit of the intcon register must be set. the instruction following the sleep instruction always executes following a wake from sleep. if the gie bit of the intcon register is also set, the device will then execute the interrupt service routine. 7.8 effects of a reset a device reset forces the cmcon0 and cmcon1 registers to their reset states. this forces the compar- ator module to be in the comparator reset mode (cm<2:0> = 000) . thus, all comparator inputs are analog inputs with the comparator disabled to consume the smallest current possible. register 7-1: cmcon0: comparator configuration register (pic12f635) u-0 r-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 c o u t cinv cis cm2 cm1 cm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 unimplemented: read as 0 bit 6 cout: comparator output bit when cinv = 0 : 1 = v in + > v in - 0 = v in + < v in - when cinv = 1 : 1 = v in + < v in - 0 = v in + > v in - bit 5 unimplemented: read as 0 bit 4 cinv: comparator output inversion bit 1 = output inverted 0 = output not inverted bit 3 cis: comparator input switch bit when cm<2:0> = 110 or 101 : 1 = cin+ connects to v in - 0 = cin- connects to v in - when cm<2:0> = 0xx or 100 or 111 : cis has no effect. bit 2-0 cm<2:0>: comparator mode bits (see figure 7-5) 000 = cin pins are configured as analog, cout pin configured as i/o, comparator output turned off 001 = cin pins are configured as analog, co ut pin configured as comparator output 010 = cin pins are configured as analog, cout pin conf igured as i/o, comparator output available internally 011 = cin- pin is configured as analog, cin+ pin is configured as i/o, cout pin configured as comparator output, cv ref is non-inverting input 100 = cin- pin is configured as analog, cin+ pin is configured as i/o, cout pin is configured as i/o, comparator output available internally, cv ref is non-inverting input 101 = cin pins are configured as analog and multiplexed, cout pin is configured as comparator output, cv ref is non-inverting input 110 = cin pins are configured as analog and multiplexed, cout pin is configured as i/o, comparator output available internally, cv ref is non-inverting input 111 = cin pins are configured as i/o, cout pin is configur ed as i/o, comparator output disabled, comparator off. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 80 ? 2007 microchip technology inc. register 7-2: cmcon0: comparator co nfiguration register (pic16f636/639) r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 c2out: comparator 2 output bit when c2inv = 0 : 1 = c2 v in + > c2 v in - 0 = c2 v in + < c2 v in - when c2inv = 1 : 1 = c2 v in + < c2 v in - 0 = c2 v in + > c2 v in - bit 6 c1out: comparator 1 output bit when c1inv = 0 : 1 = c1 v in + > c1 v in - 0 = c1 v in + < c1 v in - when c1inv = 1 : 1 = c1 v in + < c1 v in - 0 = c1 v in + > c1 v in - bit 5 c2inv: comparator 2 output inversion bit 1 = c2 output inverted 0 = c2 output not inverted bit 4 c1inv: comparator 1 output inversion bit 1 = c1 output inverted 0 = c1 output not inverted bit 3 cis: comparator input switch bit when cm<2:0> = 010 : 1 = c1in+ connects to c1 v in - c2in+ connects to c2 v in - 0 = c1in- connects to c1 v in - c2in- connects to c2 v in - when cm<2:0> = 001 : 1 = c1in+ connects to c1 v in - 0 = c1in- connects to c1 v in - bit 2-0 cm<2:0>: comparator mode bits (see figure 7-5) 000 = comparators off. cxin pins are configured as analog 001 = three inputs multiplexed to two comparators 010 = four inputs multiplexed to two comparators 011 = two common reference comparators 100 = two independent comparators 101 = one independent comparator 110 = two comparators with outputs and common reference 111 = comparators off. cxin pins are configured as digital i/o downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 81 pic12f635/pic16f636/639 7.9 comparator gating timer1 this feature can be used to time the duration or inter- val of analog events. clearing the t1gss bit of the cmcon1 register will enable timer1 to increment based on the output of the comparator (or comparator c2 for pic16f636/639). this requires that timer1 is on and gating is enabled. see section 6.0 timer1 module with gate control for details. it is recommended to synchronize the comparator with timer1 by setting the cxsync bit when the comparator is used as the timer1 gate source. this ensures timer1 does not miss an increment if the comparator changes during an increment. 7.10 synchronizing comparator output to timer1 the comparator (or comparator c2 for pic16f636/639) output can be synchronized with timer1 by setting the cxsync bit of the cmcon1 register. when enabled, the comparator output is latched on the falling edge of the timer1 clock source. if a prescaler is used with timer1, the comparator output is latched after the prescaling function. to prevent a race condition, the comparator output is latched on the falling edge of the timer1 clock source and timer1 increments on the rising edge of its clock source. see the comparator block diagram (figure 7-2) and the timer1 block diagram (figure 6-1) for more information. note: references to the comparator in this section specifically are referring to comparator c2 on the pic16f636/639. note: references to the comparator in this section specifically are referring to comparator c2 on the pic16f636/639. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 82 ? 2007 microchip technology inc. register 7-3: cmcon1: comparator configuration register (pic12f635) u-0 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 t1gss cmsync bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-2 unimplemented: read as 0 bit 1 t1gss: timer1 gate source select bit (1) 1 = timer1 gate source is t1g pin (pin should be configured as digital input) 0 = timer1 gate source is comparator output bit 0 cmsync: comparator output synchronization bit (2) 1 = output is synchronized with falling edge of timer1 clock 0 = output is asynchronous note 1: refer to section 6.6 timer1 gate . 2: refer to figure 7-2. register 7-4: cmcon1: comparator co nfiguration register (pic16f636/639) u-0 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 t1gss c2sync bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-2 unimplemented: read as 0 bit 1 t1gss: timer1 gate source select bit (1) 1 = timer1 gate source is t1g pin (pin should be configured as digital input) 0 = timer1 gate source is comparator c2 output bit 0 c2sync: comparator c2 output synchronization bit (2) 1 = output is synchronized with falling edge of timer1 clock 0 = output is asynchronous note 1: refer to section 6.6 timer1 gate . 2: refer to figure 7-4. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 83 pic12f635/pic16f636/639 7.11 comparator voltage reference the comparator voltage reference module provides an internally generated voltage reference for the comparators. the following features are available: ? independent from comparator operation ? two 16-level voltage ranges ? output clamped to v ss ? ratiometric with v dd ? fixed voltage reference the vrcon register (register 7-5) controls the voltage reference module shown in figure 7-10. 7.11.1 independent operation the comparator voltage reference is independent of the comparator configuration. setting the vren bit of the vrcon register will enable the voltage reference. 7.11.2 output voltage selection the cv ref voltage reference has 2 ranges with 16 voltage levels in each range. range selection is controlled by the vrr bit of the vrcon register. the 16 levels are set with the vr<3:0> bits of the vrcon register. the cv ref output voltage is determined by the following equations: equation 7-1: cv ref output voltage (internal cv ref ) equation 7-2: cv ref output voltage (external cv ref ) the full range of v ss to v dd cannot be realized due to the construction of the module. see figure 7-10. 7.11.3 output clamped to v ss the cv ref output voltage can be set to vss with no power consumption by configuring vrcon as follows: ?vren= 0 ?vrr= 1 ?vr<3:0>= 0000 this allows the comparator to detect a zero-crossing while not consuming additional cv ref module current. 7.11.4 output ratiometric to vdd the comparator voltage reference is v dd derived and therefore, the cv ref output changes with fluctuations in v dd . the tested absolute accuracy of the comparator voltage reference can be found in section 15.0 elec- trical specifications . v rr 1 (low range): = v rr 0 (high range): = cv ref (v dd /4) + = cv ref (vr<3:0>/24) v dd = (vr<3:0> v dd /32) v rr 1 (low range): = v rr 0 (high range): = cv ref (v ladder /4) + = cv ref (vr<3:0>/24) v ladder = (vr<3:0> v ladder /32 ) v ladder v dd = or ([v ref +] - [v ref -]) or v ref + downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 84 ? 2007 microchip technology inc. figure 7-10: comparator voltage reference block diagram register 7-5: vrcon: voltage reference control register r/w-0 u-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 vren v r r vr3 vr2 vr1 vr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 vren: cv ref enable bit 1 = cv ref circuit powered on 0 = cv ref circuit powered down, no i dd drain and cv ref = v ss . bit 6 unimplemented: read as 0 bit 5 vrr: cv ref range selection bit 1 = low range 0 = high range bit 4 unimplemented: read as 0 bit 3-0 vr<3:0>: cv ref value selection bits (0 vr<3:0> 15) when v rr = 1 : cv ref = (vr<3:0>/24) * v dd when v rr = 0 : cv ref = v dd /4 + (vr<3:0>/32) * v dd vrr 8r vr<3:0> (1) 16-1 analog 8r r r r r cv ref to 16 stages comparator input vren v dd mux vr<3:0> = 0000 vren vrr 0 1 2 14 15 note 1: care should be taken to ensure v ref remains within the comparator common mode input range. see section 15.0 electrical specifica- tions for more detail. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 85 pic12f635/pic16f636/639 table 7-2: summary of registers associated with the comparator and voltage reference modules name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets cmcon0 c o u t cinv cis cm2 cm1 cm0 -0-0 0000 -0-0 0000 cmcon1 t1gss cmsync ---- --10 ---- --10 intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x pie1 eeie lvdie crie c 1 i e osfie tmr1ie 000- 00-0 000- 00-0 pir1 eeif lvdif crif c 1 i f osfif tmr1if 000- 00-0 000- 00-0 porta ra5 ra4 ra3 ra2 ra1 ra0 --xx xxxx --uu uuuu portc rc5 rc4 rc3 rc2 rc1 rc0 --xx xxxx --uu uuuu trisa trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 --11 1111 --11 1111 trisc trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 --11 1111 --11 1111 vrcon vren v r r vr3 vr2 vr1 vr0 0-0- 0000 0-0- 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as 0 . shaded cells are not used for comparator. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 86 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 87 pic12f635/pic16f636/639 8.0 programmable low-voltage detect (plvd) module the programmable low-voltage detect (plvd) module is a power supply detector which monitors the internal power supply. this module is typically used in key fobs and other devices, where certain actions need to be taken as a result of a falling battery voltage. the plvd module includes the following capabilities: ? eight programmable trip points ? interrupt on falling v dd ? stable reference indication ? operation during sleep a block diagram of the plvd module is shown in figure 8-1. figure 8-1: plvd block diagram figure 8-2: plvd operation lvdl<2:0> 8-to-1 8 stages lvden v dd 7 6 2 1 0 analog mux + - lvdif voltage generator det reference plvd trip point lvdif v dd set by hardware cleared by software downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 88 ? 2007 microchip technology inc. 8.1 plvd operation to setup the plvd for operation, the following steps must be taken: ? enable the module by setting the lvden bit of the lvdcon register. ? configure the trip point by setting the lvdl<2:0> bits of the lvdcon register. ? wait for the reference voltage to become stable. refer to section 8.4 stable reference indication . ? clear the lvdif bit of the pir x register. the lvdif bit will be set when v dd falls below the plvd trip point. the lvdif bit remains set until cleared by software. refer to figure 8-2. 8.2 programmable trip point the plvd trip point is selectable from one of eight voltage levels. the lvdl bits of the lvdcon register select the trip point. refer to register 8-1 for the available plvd trip points. 8.3 interrupt on falling v dd when v dd falls below the plvd trip point, the falling edge detector will set the lvdif bit. see figure 8-2. an interrupt will be generated if the following bits are also set: ? gie and peie bits of the intcon register ? lvdie bit of the pie x register the lvdif bit must be cleared by software. an interrupt can be generated from a simulated plvd event when the lvdif bit is set by software. 8.4 stable reference indication when the plvd module is enabled, the reference volt- age must be allowed to stabilize before the plvd will provide a valid result. refer to electrical section, plvd characteristics for the stabilization time. when the hfintosc is running, the irvst bit of the lvdcon register indicates the stability of the voltage reference. the voltage reference is stable when the irvst bit is set. 8.5 operation during sleep to wake from sleep, set the lvdie bit of the pie x register and the peie bit of the intcon register. when the lvdie and peie bits are set, the device will wake from sleep and execute the next instruction. if the gie bit is also set, the program will call the interrupt service routine upon completion of the first instruction after waking from sleep. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 89 pic12f635/pic16f636/639 table 8-1: registers associated with programmable low-voltage detect register 8-1: lvdcon: low-volt age detect control register u-0 u-0 r-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 irvst (1) lvden lvdl2 lvdl1 lvdl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as 0 bit 5 irvst: internal reference voltage stable status flag bit (1) 1 = indicates that the plvd is stable and plvd interrupt is reliable 0 = indicates that the plvd is not stable and plvd interrupt must not be enabled bit 4 lvden: low-voltage detect module enable bit 1 = enables plvd module, powers up plvd circuit and supporting reference circuitry 0 = disables plvd module, powers down plvd circuit and supporting reference circuitry bit 3 unimplemented: read as 0 bit 2-0 lvdl<2:0>: low-voltage detection level bits (nominal values) 111 = 4.5v 110 = 4.2v 101 = 4.0v 100 = 2.3v (default) 011 = 2.2v 010 = 2.1v 001 = 2.0v (2) 000 = reserved note 1: the irvst bit is usable only when the hfintosc is running. 2: not tested and below minimum operating conditions. n a m eb i t 7b i t 6b i t 5b i t 4b i t 3b i t 2b i t 1b i t 0 value on por, bor value on all other resets intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x pie1 osfie c2ie c1ie lcdie l v d i e ccp2ie 0000 -0-0 0000 -0-0 pir1 osfif c2if c1if lcdif l v d i f ccp2if 0000 -0-0 0000 -0-0 lvdcon i r v s tl v d e n lvdl2 lvdl1 lvdl0 --00 -100 --00 -100 legend: x = unknown, - = unimplemented read as 0 . shaded cells are not used by the plvd module. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 90 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 91 pic12f635/pic16f636/639 9.0 data eeprom memory the eeprom data memory is readable and writable during normal operation (full v dd range). this memory is not directly mapped in the register file space. instead, it is indirectly addressed through the special function registers. there are four sfrs used to read and write this memory: ? eecon1 ? eecon2 (not a physically implemented register) ? eedat ? eeadr eedat holds the 8-bit data for read/write and eeadr holds the address of the eeprom location being accessed. pic16f636/639 has 256 bytes of data eeprom and the pic12f635 has 128 bytes. the eeprom data memory allows byte read and write. a byte write automatically erases the location and writes the new data (erase before write). the eeprom data memory is rated for high erase/write cycles. the write time is controlled by an on-chip timer. the write time will vary with voltage and temperature as well as from chip-to-chip. please refer to a/c specifications in section 15.0 electrical specifications for exact limits. when the data memory is code-protected, the cpu may continue to read and write the data eeprom memory. the device programmer can no longer access the data eeprom data and will read zeroes. register 9-1: eedat: eeprom data register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eedat7 eedat6 eedat5 eedat4 eedat3 eedat2 eedat1 eedat0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-0 eedatn : byte value to write to or read from data eeprom bits register 9-2: eeadr: eeprom address register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eeadr7 (1) eeadr6 eeadr5 eeadr4 eeadr3 eeadr2 eeadr1 eeadr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-0 eeadr : specifies one of 256 locations fo r eeprom read/write operation bits note 1: pic16f636/639 only. read as 0 on pic12f635. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 92 ? 2007 microchip technology inc. 9.1 eecon1 and eecon2 registers eecon1 is the control register with four low-order bits physically implemented. the upper four bits are non-implemented and read as 0 s. control bits rd and wr initiate read and write, respectively. these bits cannot be cleared, only set in software. they are cleared in hardware at completion of the read or write operation. the inability to clear the wr bit in software prevents the accidental, premature termination of a write operation. the wren bit, when set, will allow a write operation. on power-up, the wren bit is clear. the wrerr bit is set when a write operation is interrupted by a mclr reset, or a wdt time-out reset during normal operation. in these situations, following reset, the user can check the wrerr bit, clear it and rewrite the location. the data and address will be cleared. therefore, the eedat and eeadr registers will need to be re-initialized. interrupt flag, eeif bit of the pir1 register, is set when write is complete. this bit must be cleared in software. eecon2 is not a physical register. reading eecon2 will read all 0 s. the eecon2 register is used exclusively in the data eeprom write sequence. note: the eecon1, eedat and eeadr registers should not be modified during a data eeprom write (wr bit = 1 ). register 9-3: eecon1: eeprom control register u-0 u-0 u-0 u-0 r/w-x r/w-0 r/s-0 r/s-0 wrerr wren wr rd bit 7 bit 0 legend: s = bit can only be set r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-4 unimplemented: read as 0 bit 3 wrerr: eeprom error flag bit 1 = a write operation is prematurely terminated (any mclr reset, any wdt reset during normal operation or bor reset) 0 = the write operation completed bit 2 wren: eeprom write enable bit 1 = allows write cycles 0 = inhibits write to the data eeprom bit 1 wr: write control bit 1 = initiates a write cycle (the bit is cleared by hardware once write is complete. the wr bit can on ly be set, not cleared, in software.) 0 = write cycle to the data eeprom is complete bit 0 rd: read control bit 1 = initiates an eeprom read (read takes one cycle. rd is cleared in hardware. the rd bit can only be set, not cleared, in software.) 0 = does not initiate an eeprom read downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 93 pic12f635/pic16f636/639 9.2 reading the eeprom data memory to read a data memory location, the user must write the address to the eeadr register and then set control bit rd of the eecon1 register, as shown in example 9-1. the data is available, in the very next cycle, in the eedat register. therefore, it can be read in the next instruction. eedat holds this value until another read, or until it is written to by the user (during a write operation). example 9-1: data eeprom read 9.3 writing to the eeprom data memory to write an eeprom data location, the user must first write the address to the eeadr register and the data to the eedat register. then the user must follow a specific sequence to initiate the write for each byte, as shown in example 9-2. the write will not initiate if the above sequence is not exactly followed (write 55h to eecon2, write aah to eecon2, then set wr bit) for each byte. we strongly recommend that interrupts be disabled during this code segment. a cycle count is executed during the required sequence. any number that is not equal to the required cycles to execute the required sequence will prevent the data from being written into the eeprom. additionally, the wren bit in eecon1 must be set to enable write. this mechanism prevents accidental writes to data eeprom due to errant (unexpected) code execution (i.e., lost programs). the user should keep the wren bit clear at all times, except when updating eeprom. the wren bit is not cleared by hardware. after a write sequence has been initiated, clearing the wren bit will not affect this write cycle. the wr bit will be inhibited from being set unless the wren bit is set. at the completion of the write cycle, the wr bit is cleared in hardware and the ee write complete interrupt flag bit (eeif) is set. the user can either enable this interrupt or poll this bit. the eeif bit of the pir1 register must be cleared by software. example 9-2: data eeprom write 9.4 write verify depending on the application, good programming practice may dictate that the value written to the data eeprom should be verified (see example 9-3) to the desired value to be written. example 9-3: write verify 9.4.1 using the data eeprom the data eeprom is a high-endurance, byte addressable array that has been optimized for the storage of frequently changing information (e.g., program variables or other data that are updated often). when variables in one section change frequently, while variables in another section do not change, it is possible to exceed the total number of write cycles to the eeprom (specification d124) without exceeding the total number of write cycles to a single byte (specifications d120 and d120a). if this is the case, then a refresh of the array must be performed. for this reason, variables that change infrequently (such as constants, ids, calibration, etc.) should be stored in flash program memory. banksel eeadr ; movlw config_addr ; movwf eeadr ;address to read bsf eecon1,rd ;ee read movf eedat,w ;move data to w banksel eeadr ; bsf eecon1,wren ;enable write bcf intcon,gie ;disable ints movlw 55h ;unlock write movwf eecon2 ; movlw aah ; movwf eecon2 ; bsf eecon1,wr ;start the write bsf intcon,gie ;enable ints required sequence banksel eedat ; movf eedat,w ;eedat not changed ;from previous write bsf eecon1,rd ;yes, read the ;value written xorwf eedat,w ; btfss status,z ;is data the same goto write_err ;no, handle error : ;yes, continue downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 94 ? 2007 microchip technology inc. 9.5 protection against spurious write there are conditions when the user may not want to write to the data eeprom memory. to protect against spurious eeprom writes, various mechanisms have been built in. on power-up, wren is cleared. also, the power-up timer (nominal 64 ms duration) prevents eeprom write. the write initiate sequence and the wren bit together help prevent an accidental write during: ? brown-out ?power glitch ? software malfunction 9.6 data eeprom operation during code protection data memory can be code-protected by programming the cpd bit in the configuration word (register 12-1) to 0 . when the data memory is code-protected, the cpu is able to read and write data to the data eeprom. it is recommended to code-protect the program memory when code-protecting data memory. this prevents anyone from programming zeroes over the existing code (which will execute as nop s) to reach an added routine, programmed in unused program memory, which outputs the contents of data memory. programming unused locations in program memory to 0 will also help prevent data memory code protection from becoming breached. table 9-1: summary of registers associated with data eeprom name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x pir1 eeif lvdif crif c2if (1) c1if osfif tmr1if 0000 00-0 0000 00-0 pie1 eeie lvdie crie c2ie (1) c1ie osfie t m r 1 i e 0000 00-0 0000 00-0 eedat eedat7 eedat6 eedat5 eedat4 eedat3 eedat2 eedat1 eedat0 0000 0000 0000 0000 eeadr eeadr7 (1) eeadr6 eeadr5 eeadr4 eeadr3 eeadr2 eeadr1 eeadr0 0000 0000 0000 0000 eecon1 wrerr wren wr rd ---- x000 ---- q000 eecon2 eeprom control register 2 (not a physical register) ---- ---- ---- ---- legend: x = unknown, u = unchanged, C = unimplemented read as 0 , q = value depends upon condition. shaded cells are not used by the data eeprom module. note 1: pic16f636/639 only. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 95 pic12f635/pic16f636/639 10.0 k ee l oq ? compatible cryptographic module to obtain information regarding the implementation of the k ee l oq module, microchip technology requires the execution of the k ee l oq ? encoder license agreement. the k ee l oq ? encoder license agreement may be accessed through the microchip web site located at www.microchip.com/k ee l oq . further information may be obtained by contacting your local microchip sales representative. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 96 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 97 pic12f635/pic16f636/639 11.0 analog front-end (afe) functional description (pic16f639 only) the pic16f639 device consists of the pic16f636 device and low frequency (lf) analog front-end (afe), with the afe section containing three analog-input channels for signal detection and lf talk-back. this section describes the analog front-end (afe) in detail. the pic16f639 device can detect a 125 khz input signal as low as 1 mvpp and transmit data by using internal lf talk-back modulation or via an external transmitter. the pic16f639 can also be used for various bidirectional communication applications. figure 11-3 and figure 11-4 show application examples of the device. each analog input channel has internal tuning capacitance, sensitivity control circuits, an input signal strength limiter and an lf talk-back modulation transistor. an automatic gain control (agc) loop is used for all three input channel gains. the output of each channel is ord and fed into a demodulator. the digital output is passed to the lfdata pin. figure 11-1 shows the block diagram of the afe and figure 11-2 shows the lc input path. there are a total of eight configuration registers. six of them are used for afe operation options, one for column parity bits and one for status indication of afe operation. each register has 9 bits including one row parity bit. these registers are readable and writable by spi (serial protocol interface) commands except for the status register, which is read-only. 11.1 rf limiter the rf limiter limits lc pin input voltage by de-qing the attached lc resonant circuit. the absolute voltage limit is defined by the silicon processs maximum allowed input voltage (see section 15.0 electrical specifications ). the limiter begins de-qing the external lc antenna when the input voltage exceeds v de _ q , progressively de-qing harder to reduce the antenna input voltage. the signal levels from all 3 channels are combined such that the limiter attenuates all 3 channels uniformly, in respect to the channel with the strongest signal. 11.2 modulation circuit the modulation circuit consists of a modulation transistor (fet), internal tuning capacitors and external lc antenna components. the modulation transistor and the internal tuning capacitors are connected between the lc input pin and lccom pin. each lc input has its own modulation transistor. when the modulation transistor turns on, its low turn-on resistance (r m ) clamps the induced lc antenna voltage. the coil voltage is minimized when the modulation transistor turns-on and maximized when the modulation transistor turns-off. the modulation transistors low turn-on resistance (r m ) results in a high modulation depth. the lf talk-back is achieved by turning on and off the modulation transistor. the modulation data comes from the microcontroller section via the digital spi interface as clamp on, clamp off commands. only those inputs that are enabled will execute the clamp command. a basic block diagram of the modulation circuit is shown in figure 11-1 and figure 11-2. the modulation fet is also shorted momentarily after soft reset and inactivity timer time-out. 11.3 tuning capacitor each channel has internal tuning capacitors for external antenna tuning. the capacitor values are programmed by the configuration registers up to 63 pf, 1 pf per step. 11.4 variable attenuator the variable attenuator is used to attenuate, via agc control, the input signal voltage to avoid saturating the amplifiers and demodulators. 11.5 sensitivity control the sensitivity of each channel can be reduced by the channels configuration register sensitivity setting. this is used to desensitize the channel from optimum. note: the user can control the tuning capacitor by programming the afe configuration registers. note: the variable attenuator function is accomplished by the device itself. the user cannot control its function. note: the user can desensitize the channel sensitivity by programming the afe configuration registers. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 98 ? 2007 microchip technology inc. 11.6 agc control the agc controls the variable attenuator to limit the internal signal voltage to avoid saturation of internal amplifiers and demodulators (refer to section 11.4 variable attenuator ). the signal levels from all 3 channels are combined such that agc attenuates all 3 channels uniformly in respect to the channel with the strongest signal. 11.7 fixed gain amplifiers 1 and 2 fga1 and fga2 provides a maximum two-stage gain of 40 db. 11.8 auto channel selection the auto channel selection feature is enabled if the auto channel select bit autochsel<8> in configu- ration register 5 (register 11-6) is set, and disabled if the bit is cleared. when this feature is active (i.e., autochse <8> = 1 ), the control circuit checks the demodulator output of each input channel immediately after the agc settling time (t stab ). if the output is high, it allows this channel to pass data, otherwise it is blocked. the status of this operation is monitored by afe status register 7 bits <8:6> (register 11-8). these bits indicate the current status of the channel selection activity, and automatically updates for every soft reset period. the auto channel selection function resets after each soft reset (or after inactivity time r time-out). therefore, the blocked channels are reenabled after soft reset. this feature can make the output signal cleaner by blocking any channel that was not high at the end of t agc . this function works only for demodulated data output, and is not applied for carrier clock or rssi output. 11.9 carrier clock detector the detector senses the input carrier cycles. the output of the detector switches digitally at the signal carrier frequency. carrier clock output is available when the output is selected by the datout bit in the afe configuration register 1 (register 11-2). 11.10 demodulator the demodulator consists of a full-wave rectifier, low pass filter, peak detector and data slicer that detects the envelope of the input signal. 11.11 data slicer the data slicer consists of a reference generator and comparator. the data slicer compares the input with the reference voltage. the reference voltage comes from the minimum modulation depth requirement setting and input peak voltage. the data from all 3 channels are ord together and sent to the output enable filter. 11.12 output enable filter the output enable filter enables the lfdata output once the incoming signal meets the wake-up sequence requirements (see section 11.15 configurable output enable filter ). 11.13 rssi (received signal strength indicator) the rssi provides a current which is proportional to the input signal amplitude (see section 11.31.3 received signal strength indicator (rssi) output ). 11.14 analog front-end timers the afe has an internal 32 khz rc oscillator. the oscillator is used in several timers: ? inactivity timer ? alarm timer ? pulse width timer ? period timer ? agc settling timer 11.14.1 rc oscillator the rc oscillator is low power, 32 khz 10% over temperature and voltage variations. note: the agc control function is accomplished by the device itself. the user cannot control its function. note: the user cannot control the gain of these two amplifiers. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 99 pic12f635/pic16f636/639 11.14.2 inactivity timer the inactivity timer is used to automatically return the afe to standby mode, if there is no input signal. the time-out period is approximately 16 ms (t inact ), based on the 32 khz internal clock. the purpose of the inactivity timer is to minimize afe current draw by automatically returning the afe to the lower current standby mode, if there is no input signal for approximately 16 ms. the timer is reset when: ? an amplitude change in lf input signal, either high-to-low or low-to-high ?cs pin is low (any spi command) ? timer-related soft reset the timer starts when: ? afe receives any lf signal the timer causes an afe soft reset when: ? a previously received lf signal does not change either high-to-low or low-to-high for t inact the soft reset returns the afe to standby mode where most of the analog circuits, such as the agc, demodulator and rc oscillator, are powered down. this returns the afe to the lower standby current mode. 11.14.3 alarm timer the alarm timer is used to notify the mcu that the afe is receiving lf signal that does not pass the output enable filter requirement. the time-out period is approximately 32 ms (t alarm ) in the presence of continuing noise. the alarm timer time-out occurs if there is an input signal for longer than 32 ms that does not meet the output enable filter requirements. the alarm timer time-out causes: a) the alert pin to go low. b) the alarm bit to set in the afe status configuration 7 register (register 11-8). the mcu is informed of the alarm timer time-out by monitoring the alert pin. if the alarm timer time-out occurs, the mcu can take appropriate actions such as lowering channel sensitivity or disabling channels. if the noise source is ignored, the afe can return to a lower standby current draw state. the timer is reset when the: ?cs pin is low (any spi command). ? output enable filter is disabled. ? lfdata pin is enabled (signal passed output enable filter). the timer starts when: ? receiving a lf signal. the timer causes a low output on the alert pin when: ? output enable filter is enabled and modulated input signal is present for t alarm , but does not pass the output enable filter requirement. 11.14.4 pulse width timer the pulse width timer is used to verify that the received output enable sequence meets both the minimum t oeh and minimum t oel requirements. 11.14.5 period timer the period timer is used to verify that the received output enable sequence meets the maximum t oet requirement. 11.14.6 agc settling timer (t agc ) this timer is used to keep the output enable filter in reset while the agc settles on the input signal. the time-out period is approximately 3.5 ms. at end of this time (t agc ), the input should remain high (t pagc ), otherwise the counting is aborted and a soft reset is issued. see figure 11-6 for details. note: the alarm timer is disabled if the output enable filter is disabled. note 1: the afe needs continuous and uninterrupted high input signal during agc settling time (t agc ). any absence of signal during this time may reset the timer and a new input signal is needed for agc settling time, or may result in improper agc gain settings which will produce invalid output. 2: the rest of the afe section wakes up if any of these input channels receive the agc settling time correctly. afe status register 7 bits <4:2> (register 11-8) indicate which input channels have waken up the afe first. valid input signal on multiple input pins can cause more than one channels indicator bit to be set. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 100 ? 2007 microchip technology inc. figure 11-1: functional block diagram C analog front-end configuration to tuning cap x to tuning cap y to tuning cap z to modulation v sst lcx lcy lcz lccom transistors registers v ddt to sensitivity z to sensitivity y to sensitivity x modulation depth agc preserve lccom detector detector detector cs lfdata/rssi/ sclk/alert mcu command decoder/controller mod tune x output enable rf lim lccom mod tune y rf lim mod tune z rf lim 32 khz oscillator b a a a agc agc agc sensitivity control x sensitivity control y sensitivity control z filter agc timer rssi cclk/sdio 64 64 64 watchdog wakex wakez wakey downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 101 pic12f635/pic16f636/639 figure 11-2: lc input path a a rf limiter mod fet capacitor tuning var atten fga1 fga2 full-wave lfdata xy z lcx/ lcy/ lcz lccom carrier >4v pp wakez wakey clkdiv datout agc feedback peak ref gen 0.1v xy z b agcact agcsig demodulator decode agc registers configuration sens. control legend: fga = fixed gain amplifier fwr = full-wave rectifier lpf = low-pass filter pd = peak detector 00 detector + C + C + C 0.4v data slicer mod depth control output enable filter 10 amplifier rectifier low-pass filter detector auto channel selector 32 khz clock/agc /1 or /4 c chxchy chz act autochsel lfdata 0110 11 rssi gen c timer 64 rssi detz dety detx wakex downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 102 ? 2007 microchip technology inc. figure 11-3: bidirectional passive keyless entry (pke) system application example figure 11-4: passive keyless entry (pke) transponder configuration example led uhf transmitter 3 input analog front-end mcu ( pic16f636 ) + pic16f639 led uhf receiver lf transmitter/ receiver microcontroller (mcu) l f c o m m a n d ( 1 2 5 k h z ) l f t a l k - b a c k ( 1 2 5 k h z ) r e s p o n s e ( u h f ) e n c r y p t e d c o d e s base station transponder ant. x ant. y ant. z pic16f639 12 3 4 2019 18 17 56 7 1615 14 89 10 1312 11 +3v +3v +3v +3v v dd s0s1 s2 s3s4 s5 v ss data rfen lfdata/rssi/cclk/sdio v ddt lcxlcy cs sclk/alert v sst ledlccom lcz rf circuitry (uhf tx) 315 mhz air-core coil ferrite-core coil ferrite-core coil downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 103 pic12f635/pic16f636/639 11.15 configurable output enable filter the purpose of this filter is to enable the lfdata output and wake the microcontroller only after receiving a specific sequence of pulses on the lc input pins. therefore, it prevents the afe from waking up the microcontroller due to noise or unwanted input signals. the circuit compares the timing of the demodulated header waveform with a pre-defined value, and enables the demodulated lfdata output when a match occurs. the output enable filter consists of a high (t oeh ) and low duration (t oel ) of a pulse immediately after the agc settling gap time. the selection of high and low times further implies a max period time. the output enable high and low times are determined by spi interface programming. figure 11-5 and figure 11-6 show the output enable filter waveforms. there should be no missing cycles during t oeh . missing cycles may result in failing the output enable condition. figure 11-5: output enable filter timing data packet t t oeh t t oel required output enable sequence lfdata output is enabled on this rising edge t t oet demodulator output t gap afe wake-up and agc stabilization start bit agc gap pulse (t agc + t pagc ) t stab downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 104 ? 2007 microchip technology inc. figure 11-6: output enable filter timing example (detailed) lf coil input lfdata output low standby mode current filter is passed and lfdata is enabled gap t pagc legend: t agc = agc stabilization time t e = time element of pulse t gap = agc stabilization gap t oeh = minimum output enable filter high time t oel = minimum output enable filter low time t oet = maximum output enable filter period t pagc = high time after t agc t stab =t agc + t pagc 3.5 ms filter starts t gap start bit (need t stab t t oeh t t oel t t oet t t e (afe stabilization) high) pulse t agc (agc settling time) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 105 pic12f635/pic16f636/639 table 11-1: typical output enable filter timing t oeh is measured from the rising edge of the demodulator output to the first falling edge. the pulse width must fall within t oeh t t oet . t oel is measured from the falling edge of the demodulator output to the rising edge of the next pulse. the pulse width must fall within t oel t t oet . t oet is measured from rising edge to the next rising edge (i.e., the sum of t oeh and t oel ). the pulse width must be t t oet . if the configuration register 0 (register 11-1), oel<8:7> is set to 00 , then t oeh must not exceed t oet and t oel must not exceed t inact . the filter will reset, requiring a complete new successive high and low period to enable lfdata, under the following conditions. ? the received high is not greater than the configured minimum t oeh value. ?during t oeh , a loss of signal > 56 s. a loss of signal < 56 s may or may not cause a filter reset. ? the received low is not greater than the configured minimum t oel value. ? the received sequence exceeds the maximum t oet value: -t oeh + t oel > t oet -or t oeh > t oet -or t oel > t oet ? a soft reset spi command is received. if the filter resets due to a long high (t oeh > t oet ), the high-pulse timer will not begin timing again until after a gap of t e and another low-to-high transition occurs on the demodulator output. disabling the output enable filter disables the t oeh and t oel requirement and the afe passes all received lf data. see figure 11-10, figure 11-11 and figure 11-12 for examples. when viewed from an application perspective, from the pin input, the actual output enable filter timing must fac- tor in the analog delays in the input path (such as demodulator charge and discharge times). ? t oeh - t dr + t df ? t oel + t dr - t df the output enable filter starts immediately after t gap , the gap after agc stabilization period. 11.16 input sensitivity control the afe is designed to have typical input sensitivity of 3mv pp . this means any input signal with amplitude greater than 3 mv pp can be detected. the afes internal agc loop regulates the detecting signal amplitude when the input level is greater than approximately 20 mv pp . this signal amplitude is called agc-active level. the agc loop regulates the input voltage so that the input signal amplitude range will be kept within the linear range of the detection circuits without saturation. the agc active status bit agcact<5>, in the afe status register 7 (register 11-8) is set if the agc loop regulates the input voltage. table 11-2 shows the input sensitivity comparison when the agcsig option is used. when agcsig option bit is set, the demodulated output is available only when the agc loop is active (see table 11-1). the afe has also input sensitivity reduction options per each channel. the configuration register 3 (register 11-4), configuration register 4 (register 11-5) and configuration register 5 (register 11-6) have the option to reduce the channel gains from 0 db to approximately -30 db. oeh <1:0> oel <1:0> t oeh (ms) t oel (ms) t oet (ms) 01 00 113 01 01 113 01 10 124 01 11 146 10 00 214 10 01 214 10 10 225 10 11 248 11 00 416 11 01 416 11 10 428 11 11 441 0 00 xx filter disabled note 1: typical at room temperature and v dd = 3.0v, 32 khz oscillator. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 106 ? 2007 microchip technology inc. table 11-2: input sensitivity vs. modulated signal strength setting (agcsig <7>) 11.17 input channels (enable/disable) each channel can be individually enabled or disabled by programming bits in configuration register 0<3:1> (register 11-1). the purpose of having an option to disable a particular channel is to minimize current draw by powering down as much circuitry as possible, if the channel is not needed for operation. the exact circuits disabled when an input is disabled are amplifiers, detector, full-wave rectifier, data slicer, and modulation fet. however, the rf input limiter remains active to protect the silicon from excessive antenna input voltages. 11.18 agc amplifier the circuit automatically amplifies input signal voltage levels to an acceptable level for the data slicer. fast attack and slow release by nature, the agc tracks the carrier signal level and not the modulated data bits. the agc inherently tracks the strongest of the three antenna input signals. the agc requires an agc stabilization time (t agc ). the agc will attempt to regulate a channels peak signal voltage into the data slicer to a desired regulated agc voltage C reducing the input paths gain as the signal level attempts to increase above regulated agc voltage, and allowing full amplification on signal levels below the regulated agc voltage. the agc has two modes of operation: 1. during the agc settling time (t agc ), the agc time constant is fast, allowing a reasonably short acquisition time of the continuous input signal. 2. after t agc , the agc switches to a slower time constant for data slicing. also, the agc is frozen when the input signal envelope is low. the agc tracks only high envelope levels. 11.19 agc preserve the agc preserve feature allows the afe to preserve the agc value during the agc settling time (t agc ) and apply the value to the data slicing circuit for the following data streams instead of using a new tracking value. this feature is useful to demodulate the input signal correctly when the input has random amplitude variations at a given time period. this feature is enabled when the afe receives an agc preserve on command and disabled if it receives an agc preserve off command. once the agc preserve on command is received, the afe acquires a new agc value during each agc settling time and preserves the value until a soft reset or an agc preserve off command is issued. therefore, it does not need to issue another agc preserve on command. an agc preserve off command is needed to disable the agc preserve feature (see section 11.32.2.5 agc preserve on command and section 11.32.2.6 agc preserve off command for agc preserve commands). agcsig<7> (config. register 5) description input sensitivity (typical) 0 disabled C the afe passes signal of any amplitude level it is capable of detecting (demodulated data and carrier clock). 3.0 mv pp 1 enabled C no output until agc status = 1 (i.e., v peak 20 mv pp ) (demodulated data and carrier clock). ? provides the best signal to noise ratio. 20 mv pp downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 107 pic12f635/pic16f636/639 11.20 soft reset the afe issues a soft reset in the following events: a) after power-on reset (por), b) after inactivity timer time-out, c) if an abort occurs, d) after receiving spi soft reset command. the abort occurs if there is no positive signal detected at the end of the agc stabilization period (t agc ). the soft reset initializes internal circuits and brings the afe into a low current standby mode operation. the internal circuits that are initialized by the soft reset include: ? output enable filter ?agc circuits ? demodulator ? 32 khz internal oscillator the soft reset has no effect on the configuration register setup, except for some of the afe status register 7 bits. (register 11-8). the circuit initialization takes one internal clock cycle (1/32 khz = 31.25 s). during the initialization, the modulation transistors between each input and lccom pins are turned-on to discharge any inter- nal/external parasitic charges. the modulation transis- tors are turned-off immediately after the initialization time. the soft reset is executed in active mode only. it is not valid in standby mode. 11.21 minimum modulation depth requirement for input signal the afe demodulates the modulated input signal if the modulation depth of the input signal is greater than the minimum requirement that is programmed in the afe configuration register 5 (register 11-6). figure 11-7 shows the definition of the modulation depth and examples. modmin<6:5> of the configuration register 5 offer four options. they are 75%, 50%, 25% and 12%, with a default setting of 50%. the purpose of this feature is to enhance the demodulation integrity of the input signal. the 12% setting is the best choice for the input signal with weak modulation depth, which is typically observed near the high-voltage base station antenna and also at far-distance from the base station antenna. it gives the best demodulation sensitivity, but is very susceptible to noise spikes that can result in a bit detection error. the 75% setting can reduce the bit errors caused by noise, but gives the least demodulation sensitivity. see table 11-3 for minimum modulation depth requirement settings. table 11-3: setting for minimum modulation depth requirement modmin bits (config. register 5) modulation depth bit 6 bit 5 00 50% (default) 01 75% 10 25% 11 12% downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 108 ? 2007 microchip technology inc. figure 11-7: modulation depth examples (a) modulation depth definition (b) lfdata output vs. input vs. minimum modulation depth setting b a a - b a x 100% modulation depth (%) = 10 - 7 10 x 100% = 30% amplitude 10 mv pp 7 mv pp amplitude modulation depth (%) = t t demodulated lfdata output when modmin setting = 25% demodulated lfdata output if modmin setting = 50% input signal with modulation depth = 30% coil input strength amplitude 0 (lfdata output = not toggled) t t (lfdata output = toggled) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 109 pic12f635/pic16f636/639 11.22 low-current sleep mode the sleep command from the microcontroller, via an spi interface command, places the afe into an ultra low-current mode. all circuits including the rf limiter, except the minimum circuitry required to retain register memory and spi capability, will be powered down to minimize the afe current draw. power-on reset or any spi command, other than sleep command, is required to wake the afe from sleep. 11.23 low-current standby mode the afe is in standby mode when no lf signal is present on the antenna inputs but the afe is powered and ready to receive any incoming signals. 11.24 low-current operating mode the afe is in low-current operating mode when a lf signal is present on an lf antenna input and internal circuitry is switching with the received data. 11.25 error detection of afe configuration register data the afes configuration registers are volatile memory. therefore, the contents of the registers can be corrupted or cleared by any electrical incidence such as battery disconnect. to ensure the data integrity, the afe has an error detection mechanism using row and column parity bits of the configuration register memory map. the bit 0 of each register is a row parity bit which is calculated over the eight configuration bits (from bit 1 to bit 8). the column parity register (configuration register 6) holds column parity bits; each bit is calculated over the respective columns (configuration registers 0 to 5) of the configuration bits. the status register is not included for the column parity bit calculation. parity is to be odd. the parity bit set or cleared makes an odd number of set bits. the user needs to calculate the row and column parity bits using the contents of the registers and program them. during operation, the afe continuously calculates the row and column parity bits of the configuration memory map. if a parity error occurs, the afe lowers the sclk/alert pin (interrupting the microcontroller section) indicating the configuration memory has been corrupted or unloaded and needs to be reprogrammed. at an initial condition after a power-on-reset, the values of the registers are all clear (default condition). therefore, the afe will issue the parity bit error by lowering the sclk/alert pin. if user reprograms the registers with correct parity bits, the sclk/alert pin will be toggled to logic high level immediately. the parity bit errors do not change or affect the afes functional operation. table 11-4 shows an example of the register values and corresponding parity bits. table 11-4: afe configuration register parity bit example register name bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 (row parity) configuration register 010101000 0 configuration register 1 00000000 1 configuration register 2 00000000 1 configuration register 3 00000000 1 configuration register 4 00000000 1 configuration register 5 10000000 0 configuration register 6 (column parity register) 11010111 1 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 110 ? 2007 microchip technology inc. 11.26 factory calibration microchip calibrates the afe to reduce the device-to-device variation in standby current, internal timing and sensitivity, as well as channel-to-channel sensitivity variation. 11.27 de-qing of antenna circuit when the transponder is close to the base station, the transponder coil may develop coil voltage higher than v de _ q . this condition is called near field. the afe detects the strong near field signal through the agc control, and de-qing the antenna circuit to reduce the input signal amplitude. 11.28 battery back-up and batteryless operation the device supports both battery back-up and batteryless operation by the addition of external components, allowing the device to be partially or completely powered from the field. figure 11-8 shows an example of the external circuit for the battery back-up. figure 11-8: lf field powering and battery back-up example note: voltage on l ccom combined with coil input voltage must not exceed the maximum lc input voltage. lcx lcy lcz v bat d block c pool d flat 1 r lim lccom c com air coil d flat 2 c z c y c x v dd r com d lim l x l y l z legend: c com = lccom charging capacitor. c pool = pool capacitor (or battery back-up capacitor), charges in field and powers device. d block = battery protection from reverse charge. schottky for low forward bias drop. d flat = field rectifier diodes. d lim = voltage limiting diode, may be required to limit v dd voltage when in strong fields. r com =c com discharge path. r lim = current limiting resistor, required for air coil in strong fields. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 111 pic12f635/pic16f636/639 11.29 demodulator the demodulator recovers the modulation data from the received signal, containing carrier plus data, by appropriate envelope detection. the demodulator has a fast rise (charge) time (t dr ) and a fall time (t df ) appropriate to an envelope of input signal (see section 15.0 electrical specifications for t dr and t df specifications). the demodulator contains the full-wave rectifier, low-pass filter, peak detector and data slicer. figure 11-9: demodulator charge and discharge 11.30 power-on reset this circuit remains in a reset state until a sufficient supply voltage is applied to the afe. the reset releases when the supply is sufficient for correct afe operation, nominally v por of afe. the configuration registers are all cleared on a power-on reset. as the configuration registers are protected by odd row and column parity, the alert pin will be pulled down C indicating to the microcontroller section that the afe configuration memory is cleared and requires loading. 11.31 lfdata output selection the lfdata output can be configured to pass the demodulator output, received signal strength indicator (rssi) output, or carrier clock. see configuration register 1 (register 11-2) for more details. 11.31.1 demodulator output the demodulator output is the default configuration of the output selection. this is the output of an envelope detection circuit. see figure 11-9 for the demodulator output. for a clean data output or to save operating power, the input channels can be individually enabled or disabled. if more than one channel is enabled, the output is the sum of each output of all enabled channels. there will be no valid output if all three channels are disabled. when the demodulated output is selected, the output is available in two different conditions depending on how the options of configuration register 0 (register 11-1) are set: output enable filter is disabled or enabled. related configuration register bits: ? configuration register 1 (register 11-2), datout <8:7>: -bit 8 bit 7 00 : demodulator output 01 : carrier clock output 10 : rssi output 01 : rssi output ? configuration register 0 (register 11-1): all bits full-wave rectifier output signal into lc input pins data slicer output t dr t df (demodulator output) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 112 ? 2007 microchip technology inc. case i. when output enable filter is disabled: demodulated output is available immediately after the agc stabilization time (t agc ). figure 11-10 shows an example of demodulated out put when the output enable filter is disabled. figure 11-10: input signal and demodulator output when the output enable filter is disabled case ii. when output enable filter is enabled : demodulated output is available only if the incoming signal meets the enable filter timing criteria that is defined in the configurat ion register 0 (register 11-1). if the criteria is met, the outpu t is available after the low timing (t oel ) of the enable filter. figure 11-11 and figure 11-12 shows examples of demodulated output when the output enable filter is enabled. input signal lfdata output downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 113 pic12f635/pic16f636/639 figure 11-11: input signal and demodulator output (when output enable filter is enabled and input meets filter timing requirements) figure 11-12: no demodulator output (when output enable filter is enabled but input does not meet filter timing requirements) input signal lfdata output input signal no lfdata output downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 114 ? 2007 microchip technology inc. 11.31.2 carrier clock output when the carrier clock output is selected, the lfdata output is a square pulse of the input carrier clock and available as soon as the agc stabilization time (t agc ) is completed. there are two configuration register options for the carrier clock output: (a) clock divide-by one or (b) clock divide-by four, depending on bit datout<7> of configuration register 2 (register 11-3). the carrier clock output is available immediately after the agc settling time. the output enable filter, agcsig, and modmin options are applicable for the carrier clock output in the same way as the demodulated output. the input channel can be individually enabled or disabled for the output. if more than one channel is enabled, the output is the sum of each output of all enabled channels. therefore, the carrier clock output waveform is not as precise as when only one channel is enabled. it is recommended to enable one channel only if a precise output waveform is desired. there will be no valid output if all three channels are disabled. see figure 11-13 for carrier clock output examples. related configuration register bits : ? configuration register 1 (register 11-2), datout <8:7>: bit 8 bit 7 00 : demodulator output 01 : carrier clock output 10 : rssi output 11 : rssi output ? configuration register 2 (register 11-3), clkdiv<7>: 0 : carrier clock/1 1 : carrier clock/4 ? configuration register 0 (register 11-1): all bits are affected ? configuration register 5 (register 11-6) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 115 pic12f635/pic16f636/639 figure 11-13: carrier clock output examples (a) carrier clock output with carrier/1 option carrier clock output carrier input (b) carrier clock output with carrier/4 option carrier input carrier clock output downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 116 ? 2007 microchip technology inc. 11.31.3 received signal strength indicator (rssi) output an analog current is available at the lfdata pin when the received signal strength indicator (rssi) output is selected for the afes configuration register. the analog current is linearly proportional to the input signal strength (see figure 11-15). all timers in the circuit, such as inactivity timer, alarm timer, and agc settling time, are disabled during the rssi mode. therefore, the rssi output is not affected by the agc settling time, and available immediately when the rssi option is selected. the afe enters active mode immediately when the rssi output is selected. the mcu i/o pin (rc3) connected to the lfdata pin, must be set to high-impedance state during the rssi output mode. when the afe receives an spi command during the rssi output, the rssi mode is temporary disabled until the spi interface communication is completed. it returns to the rssi mode again after the spi interface communication is completed. the afe holds the rssi mode until another output type is selected (cs low turns off the rssi signal). to obtain the rssi output for a particular input channel, or to save operating power, the input channel can be individually enabled or disabled. if more than one channel is enabled, the rssi output is from the strongest signal channel. there will be no valid output if all three channels are disabled. related afe configuration register bits: ? configuration register 1 (register 11-2), datout<8:7>: bit 8 bit 7 00 : demodulated output 01 : carrier clock output 10 : rssi output 11 : rssi output ? configuration register 2 (register 11-3), rssifet<8>: 0 : pull-down mosfet off 1 : pull-down mosfet on. ? configuration register 0 (register 11-1): all bits are affected. figure 11-14: rssi output path note: the pull-down mosfet option is valid only when the rssi output is selected. the mosfet is not controllable by users when demodulated or carrier clock output option is selected. rssi output current generator v dd (controlled by config. 2, bit 8) rssi pull-down mosfet current output rc3/lfdata/rssi/cclk pin rssifet off if rssi active downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 117 pic12f635/pic16f636/639 figure 11-15: rssi output current vs. input signal level example 0 10 20 30 40 50 60 70 80 90 01 23456 78 91 0 input voltage (v pp ) rssi output current (ua) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 118 ? 2007 microchip technology inc. 11.31.3.1 analog-to-digital data conversion of rssi signal the afes rssi output is an analog current. it needs an external analog-to-digital (adc) data conversion device for digitized output. the adc data conversion can be accomplished by using a stand-alone external adc device or by firmware utilizing mcus internal comparator along with a few external resistors and a capacitor. for slope adc implementations, the external capacitor at the lfdata pad needs to be discharged before data sampling. for this purpose, the internal pull-down mosfet on the lfdata pad can be utilized. the mosfet can be turned on or off with bit rssifet<8> of the configuration register 2 (register 11-3). when it is turned on, the internal mosfet provides a discharge path for the external capacitor. this mosfet option is valid only if rssi output is selected and not controllable by users for demodulated or carrier clock output options. see separate application notes for various external adc implementation methods for this device. 11.32 afe c onfiguration 11.32.1 spi communication the afe spi interface communication is used to read or write the afes configuration registers and to send command only messages. for the spi interface, the device has three pads; cs , sclk/alert , and lfdata/rssi/cclk/sdio. figure 11-15, figure 11-14, figure 11-16 and figure 11-17 shows examples of the spi communication sequences. when the device powers up, these pins will be high-impedance inputs until firmware modifies them appropriately. the afe pins connected to the mcu pins will be as follows. cs ? pin is permanently an input with an internal pull-up. sclk/alert ? pin is an open collector output when cs is high. an internal pull-up resistor exists internal to the afe to ensure no spurious spi communication between powering and the mcu configuring its pins. this pin becomes the spi clock input when cs is low. lfdata/rssi/cclk/sdio ? pin is a digital output (lfdata) so long as cs is high. during spi communication, the pin is the spi data input (sdi) unless performing a register read, where it will be the spi data output (sdo). figure 11-16: power-up sequence cs sclk/alert lfdata/rssi/ cclk/sdio alert lfdata (output) (open collector cs pulled high by internal pull-up mcu pin is input. mcu pin is input. mcu pin is input. mcu pin output driving cs high output) sclk pulled high by internal pull-up downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 119 pic12f635/pic16f636/639 figure 11-17: spi write sequence cs sclk/ lfdata/rssi/ t su t hd t cssc t sccs t hi t lo 1/f sclk t cs 1 t csh t cs 0 cclk/sdio alert lfdata sdi (output) (input) (output) sclk (input) alert (output) driven low by mcu driven low by mcu lfdata (output) mcu pin to input mcu pin to input driven low by mcu 16 clocks for write command, address and data alert mcu pin to output mcu pin still input 1 2 3 4 5 6 7 mcu spi write details: 1. drive the afes open collector alert output low. ? to ensure no false clocks occur when cs drops. 2. drop cs. ?afe sclk/alert becomes sclk input. ? lfdata/rssi/cclk/sdio becomes sdi input. 3. change lfdata/rssi/cclk/sdio connected pin to output. ? driving spi data. 4. clock in 16-bit spi write sequence - command, address, data and parity bit. ? command, address, data and parity bit. 5. change lfdata/rssi/cclk/sdio connected pin to input. 6. raise cs to complete the spi write. 7. change sclk/alert back to input. lsb msb downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 120 ? 2007 microchip technology inc. figure 11-18: spi read sequence cs lfdata/rssi/ cclk/sdio driven low by mcu t su t hd t sccs t hi t lo 1/f sclk t cs 1 t csh t cs 0 sdi (input) sclk (input) alert (output) lfdata (output) mcu pin to input mcu pin to input driven low by mcu mcu pin to output 16 clocks for read command, t cssc t cssc t cs 1 t csh t cs 0 sdo sclk (input) alert (output) lfdata (output) mcu pin to input driven low by mcu 16 clocks for read result (output) sclk/alert alert lfdata (output) (output) driven low by mcu mcu pin still input 1 2 3 4 5 6 7 8 9 10 t do msb lsb t cssc address and dummy data mcu spi read details: 1. drive the afes open collector alert output low. ? to ensure no false clocks occur when cs drops. 2. drop cs ? afe sclk/alert becomes sclk input. ? lfdata/rssi/cclk/sdio becomes sdi input. 3. change lfdata/rssi/cclk/sdio connected pin to output. ? driving spi data. 4. clock in 16-bit spi read sequence. ? command, address and dummy data. 5. change lfdata/rssi/cclk/sdio connected pin to input. 6. raise cs to complete the spi read entry of command and address. 7. drop cs. ? afe sclk/alert becomes sclk input. ? lfdata/rssi/cclk/sdio becomes sdo output. 8. clock out 16-bit spi read result. ? first seven bits clocked-out are dummy bits. ? next eight bits are the configuration register data. ? the last bit is the configuration register row parity bit. 9. raise cs to complete the spi read. 10. change sclk/alert back to input. note: the t csh is considered as one clock. therefore, the configuration register data appears at 6th clock after t csh . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 121 pic12f635/pic16f636/639 11.32.2 command decoder/controller the circuit executes 8 spi commands from the mcu. the command structure is: command (3 bits) + configuration address (4 bits) + data byte and row parity bit received by the afe most significant bit first. table 11-5 shows the available spi commands. the afe operates in spi mode 0,0. in mode 0,0 the clock idles in the low state (figure 11-19). sdi data is loaded into the afe on the rising edge of sclk and sdo data is clocked out on the falling edge of sclk. there must be multiples of 16 clocks (sclk) while cs is low or commands will abort. table 11-5: spi commands (afe) command address data row parity description command only C address and data are dont care, but need to be clocked in regardless. 000 xxxx xxxx xxxx x clamp on C enable modulation circuit 001 xxxx xxxx xxxx x clamp off C disable modulation circuit 010 xxxx xxxx xxxx x enter sleep mode (any other command wakes the afe) 011 xxxx xxxx xxxx x agc preserve on C to temporarily preserve the current agc level 100 xxxx xxxx xxxx x agc preserve off C agc again tracks strongest input signal 101 xxxx xxxx xxxx x soft reset C resets various circuit blocks read command C data will be read from the specified register address. 110 0000 config byte 0 p general C options that may change during normal operation 0001 config byte 1 p lcx antenna tuning and lfdata output format 0010 config byte 2 p lcy antenna tuning 0011 config byte 3 p lcz antenna tuning 0100 config byte 4 p lcx and lcy sensitivity reduction 0101 config byte 5 p lcz sensitivity reduction and modulation depth 0110 column parity p column parity byte for config byte 0 -> config byte 5 0111 afe status x afe status C parity error, which input is active, etc. write command C data will be written to the specified register address. 111 0000 config byte 0 p general C options that may change during normal operation 0001 config byte 1 p lcx antenna tuning and lfdata output format 0010 config byte 2 p lcy antenna tuning 0011 config byte 3 p lcz antenna tuning 0100 config byte 4 p lcx and lcy sensitivity reduction 0101 config byte 5 p lcz sensitivity reduction and modulation depth 0110 column parity p column parity byte for config byte 0 -> config byte 5 0111 not used x register is readable, but not writable note: p denotes the row parity bit (odd parity) for the respective data byte. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 122 ? 2007 microchip technology inc. figure 11-19: detailed spi interface timing (afe) 11.32.2.1 clamp on command this command results in activating (turning on) the modulation transistors of all enabled channels; channels enabled in configuration register 0 (register 11-1). 11.32.2.2 clamp off command this command results in de-activating (turning off) the modulation transistors of all channels. 11.32.2.3 sleep command this command places the afe in sleep mode C minimizing current draw by disabling all but the essential circuitry. any other command wakes the afe (example: clamp off command). 11.32.2.4 soft reset command the afe issues a soft reset when it receives an external soft reset command. the external soft reset command is typically used to end a spi communication sequence or to initialize the afe for the next signal detection sequence, etc. see section 11.20 soft reset for more details on soft reset. if a soft reset command is sent during a clamp-on condition, the afe still keeps the clamp-on condition after the soft reset execution. the soft reset is executed in active mode only, not in standby mode. the spi soft reset command is ignored if the afe is not in active mode. 11.32.2.5 agc preserve on command this command results in preserving the agc level during each agc settling time and apply the value to the data slicing circuit for the following data stream. the preserved agc value is reset by a soft reset, and a new agc value is acquired and preserved when it starts a new agc settling time. this feature is disabled by an agc preserve off command (see section 11.19 agc preserve ). 11.32.2.6 agc preserve off command this command disables the agc preserve feature and returns the afe to the normal agc tracking mode, fast tracking during agc settling time and slow tracking after that (see section 11.19 agc preserve ). 11.32.3 configuration registers the afe includes 8 configuration registers, including a column parity register and afe status register. all registers are readable and writable via spi, except status register, which is readable only. bit 0 of each register is a row parity bit (except for the afe status register 7) that makes the register contents an odd number. 123456789101 11213141516 bit 2 cs sclk sdio command data byte bit 0 bit 7 bit 0 address row parity bit bit 0 bit 3 msb lsb downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 123 pic12f635/pic16f636/639 table 11-6: analog front-end configuration registers summary register name address bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 configuration register 0 0000 oeh oel alrtind lczen lcyen lcxen r0par configuration register 1 0001 datout channel x tuning capacitor r1par configuration register 2 0010 rssifet clkdiv channel y tuning capacitor r2par configuration register 3 0011 unimplemented channel z tuning capacitor r3par configuration register 4 0100 channel x sensit ivity control channel y sensitivity control r4par configuration register 5 0101 autochsel agcsig modmin modmin channel z sen sitivity control r5par column parity register 6 0110 column parity bits r6par afe status register 7 0111 active channel indicators agcact wake-up channel indicators alar m pei register 11-1: configuration register 0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 oeh1 oeh0 oel1 oel0 alrtind lczen lcyen lcxen r0par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8-7 oeh<1:0> : output enable filter high time (t oeh ) bit 00 = output enable filter disabled (no wake-up sequence required, passes all signal to lfdata) 01 =1ms 10 =2ms 11 =4ms bit 6-5 oel<1:0> : output enable filter low time (t oel ) bit 00 =1ms 01 =1ms 10 =2ms 11 =4ms bit 4 alrtind : alert bit, output triggered by: 1 = parity error and/or expired alarm timer (receiving noise, see section 11.14.3 alarm timer ) 0 = parity error bit 3 lczen: lcz enable bit 1 = disabled 0 = enabled bit 2 lcyen: lcy enable bit 1 = disabled 0 = enabled bit 1 lcxen: lcx enable bit 1 = disabled 0 = enabled bit 0 r0par : register parity bit C set/cleared so the 9-bit r egister contains odd parity C an odd number of set bits downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 124 ? 2007 microchip technology inc. register 11-2: configuration register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 datout1 datout0 lcxtun5 lcxtun4 lcxtun3 lcxtun2 lcxtun1 lcxtun0 r1par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8-7 datout<1:0>: lfdata output type bit 00 = demodulated output 01 = carrier clock output 10 = rssi output 11 = rssi output bit 6-1 lcxtun<5:0>: lcx tuning capacitance bit 000000 = +0 pf (default) : 111111 = +63 pf bit 0 r1par : register parity bit C set/cleared so the 9-bit regi ster contains odd parity C an odd number of set bits register 11-3: configuration register 2 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 rssifet clkdiv lcytun5 lcytun4 lc ytun3 lcytun2 lcytun1 lcytun0 r2par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8 rssifet : pull-down mosfet on lfdata pad bit (controllable by user in the rssi mode only) 1 = pull-down rssi mosfet on 0 = pull-down rssi mosfet off bit 7 clkdiv: carrier clock divide-by bit 1 = carrier clock/4 0 = carrier clock/1 bit 6-1 lcytun<5:0>: lcy tuning capacitance bit 000000 = +0 pf (default) : 111111 = +63 pf bit 0 r2par : register parity bit C set/cleared so the 9-bit regi ster contains odd parity C an odd number of set bits downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 125 pic12f635/pic16f636/639 register 11-4: configuration register 3 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 lcztun5 lcztun4 lcztun3 lcztun2 lcztun1 lcztun0 r3par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8-7 unimplemented : read as 0 bit 6-1 lcztun<5:0>: lcz tuning capacitance bit 000000 = +0 pf (default) : 111111 = +63 pf bit 0 r3par : register parity bit C set/cleared so the 9-bit regi ster contains odd parity C an odd number of set bits register 11-5: configuration register 4 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 lcxsen3 lcxsen2 lcxsen1 lcxsen0 lcysen3 lcysen2 lcysen1 lcysen0 r4par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8-5 lcxsen<3:0> (1) : typical lcx sensitivity reduction bit 0000 = -0 db (default) 0001 = -2 db 0010 = -4 db 0011 = -6 db 0100 = -8 db 0101 = -10 db 0110 = -12 db 0111 = -14 db 1000 = -16 db 1001 = -18 db 1010 = -20 db 1011 = -22 db 1100 = -24 db 1101 = -26 db 1110 = -28 db 1111 = -30 db bit 4-1 lcysen<3:0> (1) : typical lcy sensitivity reduction bit 0000 = -0 db (default) :1111 = -30 db bit 0 r4par : register parity bit C set/cleared so the 9-bit regi ster contains odd parity C an odd number of set bits note 1: assured monotonic increment (or decrement) by design. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 126 ? 2007 microchip technology inc. register 11-6: configuration register 5 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 autochsel agcsig modmin1 modmin0 lczsen3 lczsen2 lczsen1 lczsen0 r5par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8 autochsel : auto channel select bit 1 = enabled C afe selects channel(s) that has demodulator output high at the end of t stab ; or otherwise, blocks the channel(s). 0 = disabled C afe follows channel enable/disable bits defined in register 0 bit 7 agcsig : demodulator output enable bit, after the agc loop is active 1 = enabled C no output until agc is regulating at around 20 mv pp at input pins. the agc active status bit is set when the agc begins regulating. 0 = disabled C the afe passes signal of any level it is capable of detecting bit 6-5 modmin<1:0> : minimum modulation depth bit 00 =50% 01 =75% 10 =25% 11 =12% bit 4-1 lczsen<3:0> (1) : lcz sensitivity reduction bit 0000 = -0db (default) : 1111 = -30db bit 0 r5par : register parity bit C set/cleared so the 9-bit register contains odd parity C an odd number of set bits note 1: assured monotonic increment (or decrement) by design. register 11-7: column parity register 6 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 colpar7 colpar6 colpar5 colpar4 colpar3 colpar2 colpar1 colpar0 r6par bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8 colpar7 : set/cleared so that this 8th parity bit + the sum of the configuration register row parity bits contain an odd number of set bits. bit 7 colpar6 : set/cleared such that this 7th parity bit + the sum of t he 7th bits in configuration registers 0 through 5 contain an odd number of set bits. bit 6 colpar5 : set/cleared such that this 6th parity bit + the sum of t he 6th bits in configuration registers 0 through 5 contain an odd number of set bits. bit 5 colpar4 : set/cleared such that this 5th parity bit + the sum of t he 5th bits in configuration registers 0 through 5 contain an odd number of set bits. bit 4 colpar3 : set/cleared such that this 4th parity bit + the sum of the 4th bits in configuration regi sters 0 through 5 contain an odd number of set bits. bit 3 colpar2 : set/cleared such that this 3rd parity bit + the sum of th e 3rd bits in configuration registers 0 through 5 contain an odd number of set bits. bit 2 colpar1 : set/cleared such that this 2nd parity bit + the sum of t he 2nd bits in configuration registers 0 through 5 contain an odd number of set bits. bit 1 colpar0 : set/cleared such that this 1st parity bit + the sum of the 1st bits in configuration registers 0 through 5 contain an odd number of set bits. bit 0 r6par : register parity bit C set/cleared so the 9-bit register contains odd parity C an odd number of set bits downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 127 pic12f635/pic16f636/639 see table 11-7 for the bit conditions of the afe status register after various spi commands and the afe power-on reset. table 11-7: afe status register bit condition (after power-on reset and various spi commands) register 11-8: afe status register 7 r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0 chzact chyact chxact agcact wakez wakey wakex alarm pei bit 8 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 8 chzact : channel z active (1) bit (cleared via soft reset) 1 = channel z is passing data after t agc 0 = channel z is not passing data after t agc bit 7 chyact : channel y active (1) bit (cleared via soft reset) 1 = channel y is passing data after t agc 0 = channel y is not passing data after t agc bit 6 chxact : channel x active (1) bit (cleared via soft reset) 1 = channel x is passing data after t agc 0 = channel x is not passing data after t agc bit 5 agcact : agc active status bit (real time, cleared via soft reset) 1 = agc is active (input signal is strong). agc is active when input signal level is approximately > 20 mv pp range. 0 = agc is inactive (input signal is weak) bit 4 wakez : wake-up channel z indicator status bit (cleared via soft reset) 1 = channel z caused a afe wake-up (passed 64 clock counter) 0 = channel z did not cause a afe wake-up bit 3 wakey : wake-up channel y indicator status bit (cleared via soft reset) 1 = channel y caused a afe wake-up (passed 64 clock counter) 0 = channel y did not cause a afe wake-up bit 2 wakex : wake-up channel x indicator status bit (cleared via soft reset) 1 = channel x caused a afe wake-up (passed 64 clock counter) 0 = channel x did not cause a afe wake-up bit 1 alarm : indicates whether an alarm timer time-out has occurred (cleared via read status register c ommand) 1 = the alarm timer time-out has occurred. it may cause the alert output to go low depending on the state of bit 4 of the configuration register 0 0 = the alarm timer is not timed out bit 0 pei : parity error indicator bi t C indicates whether a configuration register parity error has occurred (real time) 1 = a parity error has occurred and caused the alert output to go low 0 = a parity error has not occurred note 1: bit is high whenever channel is passing data. bit is low in standby mode. condition bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 chzact chyact chxact agcact wakez wakey wakex alarm pei por 0 0 0 0 00001 read command (status register only) u u u u uuu0u sleep command u u u u uuuuu soft reset executed (1) 0 0 0 0 000uu legend: u = unchanged note 1: see section 11.20 soft reset and section 11.32.2.4 soft reset command for the condition of soft reset execution. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 128 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 129 pic12f635/pic16f636/639 12.0 special features of the cpu the pic12f635/pic16f636/639 has a host of features intended to maximize system reliability, minimize cost through elimination of external components, provide power saving features and offer code protection. these features are: ? reset - power-on reset (por) - wake-up reset (wur) - power-up timer (pwrt) - oscillator start-up timer (ost) - brown-out reset (bor) ? interrupts ? watchdog timer (wdt) ? oscillator selection ? sleep ? code protection ? id locations ? in-circuit serial programming? the pic12f635/pic16f636/639 has two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a fixed delay of 64 ms (nominal) on power-up only, designed to keep the part in reset while the power supply stabilizes. there is also circuitry to reset the device if a brown-out occurs, which can use the power-up timer to provide at least a nominal 64 ms reset. with these three functions on-chip, most applications need no external reset circuitry. the sleep mode is designed to offer a very low-current power-down mode. the user can wake-up from sleep through: ? external reset ? watchdog timer wake-up ? an interrupt several oscillator options are also made available to allow the part to fit the application. the intosc option saves system cost while the lp crystal option saves power. a set of configuration bits are used to select various options (see register 12-1). 12.1 configuration bits the configuration word bits can be programmed (read as 0 ), or left unprogrammed (read as 1 ) to select various device configurations as shown in register 12-1. these bits are mapped in program memory location 2007h. note: address 2007h is beyond the user program memory space. it belongs to the special configuration memory space (2000h- 3fffh), which can be accessed only during programming. see pic12f6xx/16f6xx memory programming specification (ds41204) for more information. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 130 ? 2007 microchip technology inc. register 12-1: config: co nfiguration word register wure fcmen ieso boren1 boren0 bit 15 bit 8 cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 bit 7 bit 0 legend: r = readable bit w = writable bit p = progra mmable u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-13 unimplemented : read as 1 bit 12 wure : wake-up reset enable bit 1 = standard wake-up and continue enabled 0 = wake-up and reset enabled bit 11 fcmen: fail-safe clock monitor enabled bit 1 = fail-safe clock monitor is enabled 0 = fail-safe clock monitor is disabled bit 10 ieso: internal external switchover bit 1 = internal external switchover mode is enabled 0 = internal external switchover mode is disabled bit 9-8 boren<1:0>: brown-out reset selection bits (1) 11 = bor enabled, sboren bit disabled 10 = bor enabled during operation and disabled in sleep, sboren bit disabled 01 = bor controlled by sboren bit of the pcon register 00 = bor and sboren bits disabled bit 7 cpd : data code protection bit (2) 1 = data memory code pr otection is disabled 0 = data memory code protection is enabled bit 6 cp : code protection bit (3) 1 = program memory code protection is disabled 0 = program memory code protection is enabled bit 5 mclre: mclr pin function select bit (4) 1 = mclr pin function is mclr 0 = mclr pin function is digital input, mclr internally tied to v dd bit 4 pwrte : power-up timer enable bit 1 = pwrt disabled 0 = pwrt enabled bit 3 wdte: watchdog timer enable bit 1 = wdt enabled 0 = wdt disabled and can be enabled by swdten bit of the wdtcon register bit 2-0 fosc<2:0>: oscillator selection bits 111 = extrc oscillator: external rc on ra5/osc1/c lkin, clkout function on ra4/osc2/clkout pin 110 = extrcio oscillator: external rc on ra5/osc1/clkin, i/o function on ra4/osc2/clkout pi n 101 = intosc oscillator: clkout function on ra4/osc2/clkout pin, i/o function on ra5/osc1/clkin 100 = intoscio oscillator: i/o function on ra4/osc2/clkout pin, i/o function on ra5/osc1/clkin 011 = ec: i/o function on ra4/osc2/clkout pin, clkin on ra5/osc1/clkin 010 = hs oscillator: high-speed crystal/resonat or on ra4/osc2/clkout and ra5/osc1/clkin 001 = xt oscillator: crystal/resonator on ra4/osc2/clkout and ra5/osc1/clkin 000 = lp oscillator: low-power crysta l on ra4/osc2/clkout and ra5/osc1/clkin note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire data eeprom will be erased when the code protection is turned off. 3: the entire program memory will be erased when the code protec tion is turned off. 4: when mclr is asserted in intosc or rc mode, the internal clock oscillator is disabled. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 131 pic12f635/pic16f636/639 12.2 reset the pic12f635/pic16f636/639 differentiates between various kinds of reset: a) power-on reset (por) b) wake-up reset (wur) c) wdt reset during normal operation d) wdt reset during sleep e) mclr reset during normal operation f) mclr reset during sleep g) brown-out reset (bor) some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a reset state on: ? power-on reset ?mclr reset ?mclr reset during sleep ?wdt reset ? brown-out reset they are not affected by a wdt wake-up since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations, as indicated in table 12-3. these bits are used in software to determine the nature of the reset. see table 12-4 for a full description of reset states of all registers. a simplified block diagram of the on-chip reset circuit is shown in figure 12-1. the mclr reset path has a noise filter to detect and ignore small pulses. see section 15.0 electrical specifications for pulse width specifications. figure 12-1: simplified block diagram of on-chip reset circuit s r q external reset mclr /v pp pin v dd osc1/ wdt module v dd rise detect ost/pwrt lfintosc wdt time-out power-on reset ost 10-bit ripple counter pwrt chip_rese t 11-bit ripple counter reset enable ost enable pwrt s leep brown-out (1) reset sboren boren<0> clki pin note 1: refer to the configuration word register (register 12-1). sleep wure ra3 change wake-up interrupt boren <1> downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 132 ? 2007 microchip technology inc. 12.3 power-on reset the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper operation. to take advantage of the por, simply connect the mclr pin through a resistor to v dd . this will eliminate external rc components usually needed to create power-on reset. a maximum rise time for v dd is required. see section 15.0 electrical specifications for details. if the bor is enabled, the maximum rise time specification does not apply. the bor circuitry will keep the device in reset until v dd reaches v bod (see section 12.6 brown-out reset (bor) ). when the device starts normal operation (exits the reset condition), device operating parameters (i.e., voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to the application note an607, power-up trouble shooting (ds00607). 12.4 wake-up reset (wur) the pic12f635/pic16f636/639 has a modified wake-up from sleep mechanism. when waking from sleep, the wur function resets the device and releases reset when v dd reaches an acceptable level. if the wure bit is enabled ( 0 ) in the configuration word register, the device will wake-up reset from sleep through one of the following events: 1. on any event that causes a wake-up event. the peripheral must be enabled to generate an interrupt or wake-up, gie state is ignored. 2. when wure is enabled, ra3 will always generate an interrupt-on-change signal during sleep. the wur , por and bor bits in the pcon register and the to and pd bits in the status register can be used to determine the cause of device reset. to allow wur upon ra3 change: 1. enable the wur function, wure configuration bit = 0 . 2. enable ra3 as an input, mclre configuration bit = 0 . 3. read porta to establish the current state of ra3. 4. execute sleep instruction. 5. when ra3 changes state, the device will wake-up and then reset. the wur bit in pcon will be cleared to 0 . 12.4.1 power-up timer (pwrt) the power-up timer provides a fixed 64 ms (nominal) time-out on power-up only, from por or brown-out reset. the power-up timer operates from the 31 khz lfintosc oscillator. for more information, see section 3.5 internal clock modes . the chip is kept in reset as long as pwrt is active. the pwrt delay allows the v dd to rise to an acceptable level. a configuration bit, pwrte , can disable (if set) or enable (if cleared or programmed) the power-up timer. the power-up timer should be enabled when brown-out reset is enabled, although it is not required. the power-up timer delay will vary from chip-to-chip due to: ?v dd variation ? temperature variation ? process variation see dc parameters for details ( section 15.0 electrical specifications ). 12.5 mclr pic12f635/pic16f636/639 has a noise filter in the mclr reset path. the filter will ignore small pulses. it should be noted that a wdt reset does not drive mclr pin low. see figure 12-2 for the recommended mclr circuit. an internal mclr option is enabled by clearing the mclre bit in the configuration word register. when cleared, mclr is internally tied to v dd and an internal weak pull-up is enabled for the mclr pin. in-circuit serial programming is not affected by selecting the internal mclr option. note: the por circuit does not produce an internal reset when v dd declines. to re-enable the por, v dd must reach v ss for a minimum of 100 s. note: voltage spikes below v ss at the mclr pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resis- tor of 50-100 should be used when applying a low level to the mclr pin, rather than pulling this pin directly to v ss . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 133 pic12f635/pic16f636/639 figure 12-2: recommended mclr circuit v dd pic12f635/pic16f636/639 mclr r11k ( or greater) c1 0.1 f (optional, not critical) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 134 ? 2007 microchip technology inc. 12.6 brown-out reset (bor) the boren0 and boren1 bits in the configuration word register select one of four bor modes. two modes have been added to allow software or hardware control of the bor enable. when boren<1:0> = 01 , the sboren bit of the pcon register enables/disables the bor allowing it to be controlled in software. by selecting boren<1:0>, the bor is automatically disabled in sleep to conserve power and enabled on wake-up. in this mode, the sboren bit is disabled. see register 12-1 for the configuration word definition. if v dd falls below v bod for greater than parameter (t bod ) (see section 15.0 electrical specifications ), the brown-out situation will reset the device. this will occur regardless of v dd slew rate. a reset is not ensured to occur if v dd falls below v bod for less than parameter (t bod ). on any reset (power-on, brown-out reset, watchdog timer, etc.), the chip will remain in reset until v dd rises above v bod (see figure 12-3). the power-up timer will now be invoked, if enabled and will keep the chip in reset an additional nominal 64 ms. if v dd drops below v bod while the power-up timer is running, the chip will go back into a brown-out reset and the power-up timer will be re-initialized. once v dd rises above v bod , the power-up timer will execute a 64 ms reset. figure 12-3: brown-out reset situations note: the power-up timer is enabled by the pwrte bit in the configuration word register. 64 ms (1) v bod v dd internal reset v bod v dd internal reset 64 ms (1) < 64 ms 64 ms (1) v bod v dd internal reset note 1: nominal 64 ms delay only if pwrte bit is programmed to 0 . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 135 pic12f635/pic16f636/639 12.7 time-out sequence on power-up, the time-out sequence is as follows: first, pwrt time-out is invoked after por has expired, then ost is activated after the pwrt time-out has expired. the total time-out will vary based on oscillator configuration and pwrte bit status. for example, in ec mode with pwrte bit erased (pwrt disabled), there will be no time-out at all. figure 12-4, figure 12-5 and figure 12-6 depict time-out sequences. the device can execute code from the intosc, while ost is active, by enabling two-speed start-up or fail-safe clock monitor (see section 3.7.2 two-speed start-up sequence and section 3.8 fail-safe clock monitor ). since the time-outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then bringing mclr high will begin execution immediately (see figure 12-5). this is useful for testing purposes or to synchronize more than one pic12f635/pic16f636/639 device operating in parallel. table 12-5 shows the reset conditions for some special registers, while table 12-4 shows the reset conditions for all the registers. 12.8 power control (pcon) register the power control register, pcon (address 8eh), has two status bits to indicate what type of reset that last occurred. bit 0 is bor (brown-out). bor is unknown on power-on reset. it must then be set by the user and checked on subsequent resets to see if bor = 0 , indicating that a brown-out has occurred. the bor status bit is a dont care and is not necessarily predictable if the brown-out circuit is disabled (boren<1:0> = 00 in the configuration word register). bit 1 is por (power-on reset). it is a 0 on power-on reset and unaffected otherwise. the user must write a 1 to this bit following a power-on reset. on a subsequent reset, if por is 0 , it will indicate that a power-on reset has occurred (i.e., v dd may have gone too low). for more information, see section 4.2.3 ultra low-power wake-up and section 12.6 brown-out reset (bor) . table 12-1: time-out in various situations table 12-2: summary of registers associated with brown-out reset table 12-3: pcon bits and their significance oscillator configuration power-up brown-out reset wake-up from sleep pwrte = 0 pwrte = 1 pwrte = 0 pwrte = 1 xt, hs, lp t pwrt + 1024 ? t osc 1024 ? t osc t pwrt + 1024 ? t osc 1024 ? t osc 1024 ? t osc rc, ec, intosc t pwrt t pwrt name bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) config (2) boren1 boren0 cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 pcon ulpwue sboren wur p o r bor --01 --qq --0u --uu status irp rp1 rp0 to pd z dc c 0001 1xxx 000q quuu legend: u = unchanged, x = unknown, C = unimplemented bit, reads as 0 , q = value depends on condition. shaded cells are not used by bor. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: see configuration word register (register 12-1) for operation of all register bits. por bor wur to pd condition 0xx11 power-on reset u0u11 brown-out reset uuu0u wdt reset uuu00 wdt wake-up uuuuu mclr reset during normal operation uuu10 mclr reset during sleep uu010 wake-up reset during sleep u0u11 brown-out reset during sleep legend: u = unchanged, x = unknown downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 136 ? 2007 microchip technology inc. figure 12-4: time-out sequence on power-up (delayed mclr ) figure 12-5: time-out sequence on power-up (delayed mclr ) figure 12-6: time-out sequence on power-up (mclr with v dd ) t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 137 pic12f635/pic16f636/639 table 12-4: initialization condition for registers register address power-on reset wake-up reset mclr reset wdt reset brown-out reset (1) wake-up reset wake-up from sleep through interrupt wake-up from sleep through wdt time-out w xxxx xxxx uuuu uuuu uuuu uuuu indf 00h/80h xxxx xxxx xxxx xxxx uuuu uuuu tmr0 01h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h/82h 0000 0000 0000 0000 pc + 1 (3) status 03h/83h 0001 1xxx 000q quuu (4) uuuq quuu (4) fsr 04h/84h xxxx xxxx uuuu uuuu uuuu uuuu porta 05h --xx xx00 --00 0000 --uu uu00 portc (6) 07h --xx xx00 --00 0000 --uu uu00 pclath 0ah/8ah ---0 0000 ---0 0000 ---u uuuu intcon 0bh/8bh 0000 000x 0000 000x uuuu uuuu (2) pir1 0ch 0000 00-0 0000 00-0 uuuu uu-u (2) tmr1l 0eh xxxx xxxx uuuu uuuu uuuu uuuu tmr1h 0fh xxxx xxxx uuuu uuuu uuuu uuuu t1con 10h 0000 0000 uuuu uuuu -uuu uuuu wdtcon 18h ---0 1000 ---0 1000 ---u uuuu cmcon0 19h 0000 0000 0000 0000 uuuu uuuu cmcon1 1ah ---- --10 ---- --10 ---- --uu option_reg 81h 1111 1111 1111 1111 uuuu uuuu trisa 85h --11 1111 --11 1111 --uu 1uuu trisc (6) 87h --11 1111 --11 1111 --uu 1uuu pie1 8ch 0000 00-0 0000 00-0 uuuu uu-u pcon 8eh --01 q-qq --0u u-uu (1,5) --0u u-uu osccon 8fh -110 q000 -110 q000 -uuu uuuu osctune 90h ---0 0000 ---u uuuu ---u uuuu wpuda 95h --11 -111 --11 -111 uuuu uuuu ioca 96h --00 0000 --00 0000 --uu uuuu wda 97h --11 -111 --11 -111 uuuu uuuu vrcon 99h 0-0- 0000 0-0- 0000 u-u- uuuu eedat 9ah 0000 0000 0000 0000 uuuu uuuu eeadr 9bh 0000 0000 0000 0000 uuuu uuuu eecon1 9ch ---- x000 ---- q000 ---- uuuu eecon2 9dh ---- ---- ---- ---- ---- ---- adresl 9eh xxxx xxxx uuuu uuuu uuuu uuuu adcon1 9fh -000 ---- -000 ---- -uuu ---- lvdcon 94h --00 -000 --00 -000 --uu -uuu crcon 110h 00-- --00 00-- --00 uu-- --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as 0 , q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affec ted differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 12-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . 6: pic16f636/639 only. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 138 ? 2007 microchip technology inc. table 12-5: initialization condition for special registers condition program counter status register pcon register power-on reset 000h 0001 1xxx --01 --0x mclr reset during normal operation 000h 000u uuuu --0u --uu mclr reset during sleep 000h 0001 0uuu --0u --uu wdt reset 000h 0000 uuuu --0u --uu wdt wake-up pc + 1 uuu0 0uuu --uu --uu brown-out reset 000h 0001 1uuu --01 --10 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu --uu --uu wake-up reset 000h 0001 1xxx --01 --0x legend: u = unchanged, x = unknown, C = unimplemented bit, reads as 0 . note 1: when the wake-up is due to an interrupt and the global interrupt enable bit, gie, is set, the pc is loaded with the interrupt vector (0004h) after execution of pc + 1. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 139 pic12f635/pic16f636/639 12.9 interrupts the pic12f635/pic16f636/639 has multiple interrupt sources: ? external interrupt ra2/int ? timer0 overflow interrupt ? porta change interrupts ? 2 comparator interrupts ? timer1 overflow interrupt ? eeprom data write interrupt ? fail-safe clock monitor interrupt the interrupt control register (intcon) and peripheral interrupt request register 1 (pir1) record individual interrupt requests in flag bits. the intcon register also has individual and global interrupt enable bits. a global interrupt enable bit gie of the intcon regis- ter enables (if set) all unmasked interrupts, or disables (if cleared) all interrupts. individual interrupts can be disabled through their corresponding enable bits in the intcon register and pie1 register. gie is cleared on reset. the return from interrupt instruction, retfie , exits the interrupt routine, as well as sets the gie bit, which re-enables unmasked interrupts. the following interrupt flags are contained in the intcon register: ? int pin interrupt ? porta change interrupt ? tmr0 overflow interrupt the peripheral interrupt flags are contained in the special register, pir1. the corresponding interrupt enable bit is contained in special register, pie1. the following interrupt flags are contained in the pir1 register: ? eeprom data write interrupt ? 2 comparator interrupts ? timer1 overflow interrupt ? fail-safe clock monitor interrupt when an interrupt is serviced: ? the gie is cleared to disable any further interrupt. ? the return address is pushed onto the stack. ? the pc is loaded with 0004h. for external interrupt events, such as the int pin or porta change interrupt, the interrupt latency will be three or four instruction cycles. the exact latency depends upon when the interrupt event occurs (see figure 12-8). the latency is the same for one or two-cycle instructions. once in the interrupt service routine, the source(s) of the interrupt can be determined by polling the interrupt flag bits. the interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid multiple interrupt requests. for additional information on timer1, comparators or data eeprom modules, refer to the respective peripheral section. 12.9.1 ra2/int interrupt external interrupt on ra2/int pin is edge-triggered; either rising if the intedg bit of the option register is set, or falling if the intedg bit is clear. when a valid edge appears on the ra2/int pin, the intf bit of the intcon register is set. this interrupt can be disabled by clearing the inte control bit of the intcon register. the intf bit must be cleared in software in the interrupt service routine before re-enabling this interrupt. the ra2/int interrupt can wake-up the processor from sleep if the inte bit was set prior to going into sleep. the status of the gie bit decides whether or not the processor branches to the interrupt vector following wake-up (0004h). see section 12.12 power-down mode (sleep) for details on sleep and figure 12-10 for timing of wake-up from sleep through ra2/int interrupt. note 1: individual interrupt flag bits are set, regardless of the status of their corresponding mask bit or the gie bit. 2: when an instruction that clears the gie bit is executed, any interrupts that were pending for execution in the next cycle are ignored. the interrupts, which were ignored, are still pending to be serviced when the gie bit is set again. note: the cmcon0 (19h) register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read 0 . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 140 ? 2007 microchip technology inc. 12.9.2 timer interrupt an overflow (ffh 00h) in the tmr0 register will set the t0if bit of the intcon register. the interrupt can be enabled/disabled by setting/clearing t0ie bit of the intcon register. see section 5.0 timer0 module for operation of the timer0 module. 12.9.3 porta interrupt an input change on porta change sets the raif bit of the intcon register. the interrupt can be enabled/disabled by setting/clearing the raie bit of the intcon register. plus, individual pins can be configured through the ioca register. figure 12-7: interrupt logic note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the raif interrupt flag may not get set. tmr1if tmr1ie c1if c1ie t0if t0ie intf inte raif raie gie peie wake-up (if in sleep mode) interrupt to cpu crie crif eeif eeie ioc-ra0 ioca0 ioc-ra1 ioca1 ioc-ra2 ioca2 ioc-ra3 ioca3 ioc-ra4 ioca4 ioc-ra5 ioca5 lvdif lvdie osfif osfie c2if (1) c2ie (1) note 1: pic16f636/639 only. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 141 pic12f635/pic16f636/639 figure 12-8: int pin interrupt timing table 12-6: summary of registers associated with interrupts name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets intcon gie peie t0ie inte raie t0if intf raif 0000 000x 0000 000x ioca ioca5 ioca4 ioca3 ioca2 ioca1 ioca0 --00 0000 --00 0000 pir1 eeif lvdif crif c2if (1) c1if osfif t m r 1 i f 0000 00-0 0000 00-0 pie1 eeie lvdie crie c2ie (1) c1ie osfie t m r 1 i e 0000 00-0 0000 00-0 legend: x = unknown, u = unchanged, C = unimplemented, read as 0 , q = value depends upon condition. shaded cells are not used by the interrupt module. note 1: pic16f636/639 only. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout (3) int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed interrupt latency (2) pc pc + 1 pc + 1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc + 1) inst (pc C 1) inst (0004h) dummy cycle inst (pc) note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-4 t cy . synchronous latency = 3 t cy , where t cy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in intosc and rc oscillator modes. 4: for minimum width of int pulse, refer to ac specifications in section 15.0 electrical specifications . 5: intf is enabled to be set any time during the q4-q1 cycles. (1) (4) (5) (1) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 142 ? 2007 microchip technology inc. 12.10 context saving during interrupts during an interrupt, only the return pc value is saved on the stack. typically, users may wish to save key registers during an interrupt (e.g., w and status registers). this must be implemented in software. since the lower 16 bytes of all banks are common in the pic12f635/pic16f636/639 (see figure 2-2), temporary holding registers, w_temp and status_temp, should be placed in here. these 16 locations do not require banking and therefore, make it easier to context save and restore. the same code shown in example 12-1 can be used to: ? store the w register. ? store the status register. ? execute the isr code. ? restore the status (and bank select bit register). ? restore the w register. example 12-1: saving status and w registers in ram note: the pic12f635/pic16f636/639 normally does not require saving the pclath. however, if computed goto s are used in the isr and the main code, the pclath must be saved and restored in the isr. movwf w_temp ;copy w to temp register swapf status,w ;swap status to be saved into w ;swaps are used because they do not affect the status bits movwf status_temp ;save status to bank zero status_temp register : :(isr) ;insert user code here : swapf status_temp,w ;swap status_temp register into w ;(sets bank to original state) movwf status ;move w into status register swapf w_temp,f ;swap w_temp swapf w_temp,w ;swap w_temp into w downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 143 pic12f635/pic16f636/639 12.11 watchdog timer (wdt) the pic12f635/pic16f636/639 wdt is code and functionally compatible with other pic16f wdt modules and adds a 16-bit prescaler to the wdt. this allows the user to have a scaler value for the wdt and tmr0 at the same time. in addition, the wdt time-out value can be extended to 268 seconds. wdt is cleared under certain conditions described in table 12-7. 12.11.1 wdt oscillator the wdt derives its time base from the 31 khz lfintosc. the lts bit does not reflect that the lfintosc is enabled. the value of wdtcon is ---0 1000 on all resets. this gives a nominal time base of 16 ms, which is compatible with the time base generated with previous pic12f635/pic16f636/639 microcontroller versions. a new prescaler has been added to the path between the intrc and the multiplexers used to select the path for the wdt. this prescaler is 16 bits and can be programmed to divide the intrc by 32 to 65536, giving the wdt a nominal range of 1 ms to 268s. 12.11.2 wdt control the wdte bit is located in the configuration word register. when set, the wdt runs continuously. when the wdte bit in the configuration word register is set, the swdten bit of the wdtcon register has no effect. if wdte is clear, then the swdten bit can be used to enable and disable the wdt. setting the bit will enable it and clearing the bit will disable it. the psa and ps<2:0> bits of the option register have the same function as in previous versions of the pic16f family of microcontrollers. see section 5.0 timer0 module for more information. figure 12-9: watchdog timer block diagram table 12-7: wdt status note: when the oscillator start-up timer (ost) is invoked, the wdt is held in reset, because the wdt ripple counter is used by the ost to perform the oscillator delay count. when the ost count has expired, the wdt will begin counting (if enabled). conditions wdt wdte = 0 cleared clrwdt command oscillator fail detected exit sleep + system clock = t1osc, extrc, hfintosc, extclk exit sleep + system clock = xt, hs, lp cleared until the end of ost 31 khz psa 16-bit wdt prescaler from tmr0 clock source prescaler (1) 8 ps<2:0> psa wdt time-out to t m r 0 wdtps<3:0> wdte from configuration word register 1 1 0 0 swdten from wdtcon lfintosc clock note 1 : this is the shared timer0/wdt prescaler. see section 5.1.3 software programmable prescaler for more information. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 144 ? 2007 microchip technology inc. table 12-8: summary of registers associated with watchdog timer register 12-2: wdtcon: watchdog timer control register u-0 u-0 u-0 r/w-0 r/w-1 r/w-0 r/w-0 r/w-0 wdtps3 wdtps2 wdtps1 wdtps0 swdten (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as 0 bit 4-1 wdtps<3:0>: watchdog timer period select bits bit value = prescale rate 0000 = 1:32 0001 = 1:64 0010 = 1:128 0011 = 1:256 0100 = 1:512 (reset value) 0101 = 1:1024 0110 = 1:2048 0111 = 1:4096 1000 = 1:8192 1001 = 1:16384 1010 = 1:32768 1011 = 1:65536 1100 = reserved 1101 = reserved 1110 = reserved 1111 = reserved bit 0 swdten: software enable or disable the watchdog timer bit (1) 1 = wdt is turned on 0 = wdt is turned off (reset value) note 1: if wdte configuration bit = 1 , then wdt is always enabled, irrespective of this control bit. if wdte configuration bit = 0 , then it is possible to turn wdt on/off with this control bit. name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets wdtcon wdtps3 wdtps2 wstps1 wdtps0 swdten ---0 1000 ---0 1000 option_reg rapu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 config cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 legend: shaded cells are not used by the watchdog timer. note 1: see register 12-1 for operation of all configuration word register bits. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 145 pic12f635/pic16f636/639 12.12 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if the watchdog timer is enabled: ? wdt will be cleared but keeps running. ?pd bit in the status register is cleared. ?to bit is set. ? oscillator driver is turned off. ? i/o ports maintain the status they had before sleep was executed (driving high, low or high-impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd or v ss , with no external circuitry drawing current from the i/o pin and the comparators and cv ref should be disabled. i/o pins that are high-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribution from on-chip pull-ups on porta should be considered. the mclr pin must be at a logic high level. 12.12.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin. 2. watchdog timer wake-up (if wdt was enabled). 3. interrupt from ra2/int pin, porta change or a peripheral interrupt. the first event will cause a device reset. the two latter events are considered a continuation of program execution. the to and pd bits in the status register can be used to determine the cause of device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. the following peripheral interrupts can wake the device from sleep: 1. tmr1 interrupt. timer1 must be operating as an asynchronous counter. 2. special event trigger (timer1 in asynchronous mode using an external clock). 3. eeprom write operation completion. 4. comparator output changes state. 5. interrupt-on-change. 6. external interrupt from int pin. other peripherals cannot generate interrupts, since during sleep, no on-chip clocks are present. when the sleep instruction is being executed, the next instruction (pc + 1) is prefetched. for the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). wake-up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction, then branches to the interrupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have a nop after the sleep instruction. the wdt is cleared when the device wakes up from sleep, regardless of the source of wake-up. 12.12.2 wake-up using interrupts when global interrupts are disabled (gie cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur: ? if the interrupt occurs before the execution of a sleep instruction, the sleep instruction will complete as a nop . therefore, the wdt and wdt prescaler and postscaler (if enabled) will not be cleared, the to bit will not be set and the pd bit will not be cleared. ? if the interrupt occurs during or after the execution of a sleep instruction, the device will immediately wake-up from sleep. the sleep instruction will be completely executed before the wake-up. therefore, the wdt and wdt prescaler and postscaler (if enabled) will be cleared, the to bit will be set and the pd bit will be cleared. even if the flag bits were checked before executing a sleep instruction, it may be possible for flag bits to become set before the sleep instruction completes. to determine whether a sleep instruction executed, test the pd bit. if the pd bit is set, the sleep instruction was executed as a nop . to ensure that the wdt is cleared, a clrwdt instruction should be executed before a sleep instruction. note 1: it should be noted that a reset generated by a wdt time-out does not drive mclr pin low. 2: the analog front-end (afe) section in the pic16f639 device is independent of the microcontrollers power-down mode (sleep). see section 11.32.2.3 sleep command for afes sleep mode. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the corresponding interrupt flag bits set, the device will immediately wake-up from sleep. the sleep instruction is completely executed. note: if wur is enabled (wure = 0 in configuration word), then the wake-up reset module will force a device reset. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 146 ? 2007 microchip technology inc. figure 12-10: wake-up from sleep through interrupt 12.13 code protection if the code protection bit(s) have not been programmed, the on-chip program memory can be read out using icsp for verification purposes. 12.14 id locations four memory locations (2000h-2003h) are designated as id locations where the user can store checksum or other code identification numbers. these locations are not accessible during normal execution but are readable and writable during program/verify mode. only the least significant 7 bits of the id locations are used. q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 clkout (4) int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed pc pc + 1 pc + 2 inst(pc) = sleep inst(pc C 1) inst(pc + 1) sleep processor in sleep inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc + 2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024 t osc (drawing not to scale). this delay does not apply to ec and rc oscillator modes. 3: gie = 1 assumed. in this case after wake-up, the processor jumps to 0004h. if gie = 0 , execution will continue in-line. 4: clkout is not available in xt, hs, lp or ec oscillator modes, but shown here for timing re ference. interrupt latency (3) note: the entire data eeprom and flash pro- gram memory will be erased when the code protection is turned off. see the pic12f6xx/16f6xx memory program- ming specification (ds41204) for more information. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 147 pic12f635/pic16f636/639 12.15 in-circuit serial programming the pic12f635/pic16f636/639 microcontrollers can be serially programmed while in the end application circuit. this is simply done with two lines for clock and data and three other lines for: ?power ?ground ? programming voltage this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. the device is placed into a program/verify mode by hold- ing the ra0 and ra1 pins low, while raising the mclr (v pp ) pin from v il to v ihh . see the pic12f6xx/16f6xx memory programming specification (ds41204) for more information. ra0 becomes the programming data and ra1 becomes the programming clock. both ra0 and ra1 are schmitt trigger inputs in this mode. after reset, to place the device into program/verify mode, the program counter (pc) is at location 00h. a 6-bit command is then supplied to the device. depending on the command, 14 bits of program data are then supplied to or from the device, depending on whether the command was a load or a read. for complete details of serial programming, please refer to the pic12f6xx/16f6xx memory programming specification (ds41204). a typical in-circuit serial programming connection is shown in figure 12-11. figure 12-11: typical in-circuit serial programming connection 12.16 in-circuit debugger since in-circuit debugging requires the loss of clock, data and mclr pins, mplab ? icd 2 development with a 14-pin device is not practical. a special 20-pin pic16f636 icd device is used with mplab icd 2 to provide separate clock, data and mclr pins and frees all normally available pins to the user. use of the icd device requires the purchase of a special header. on the top of the header is an mplab icd 2 connector. on the bottom of the header is a 14-pin socket that plugs into the users target via the 14-pin stand-off connector. when the icd pin on the pic16f636 icd device is held low, the in-circuit debugger functionality is enabled. this function allows simple debugging functions when used with mplab icd 2. when the microcontroller has this feature enabled, some of the resources are not available for general use. table 12-9 shows which features are consumed by the background debugger: table 12-9: debugger resources for more information, see the mplab ? icd 2 in-circuit debugger users guide (ds51331), available on microchips web site (www.microchip.com). figure 12-12: 20-pin icd pinout external connector signals to n o r m a l connections to n o r ma l connections pic16f636 v dd v ss mclr /v pp /ra3 ra1 ra0 +5v 0v v pp clk data i/o * * * * *isolation devices (as required). resource description i/o pins icdclk, icddata stack 1 level program memory address 0h must be nop 700h-7ffh 20-pin pdip pic16f636-icd in-circuit debug device nc icdmclr /v pp v dd ra5 ra4 ra3 icdclk icddata v ss ra0 icd ra1 ra2 rc5rc4 rc3 rc0rc1 rc2 1 23 4 5 6 7 8 9 10 2019 18 17 16 15 14 13 12 11 enport downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 148 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 149 pic12f635/pic16f636/639 13.0 instruction set summary the pic12f635/pic16f636/639 instruction set is highly orthogonal and is comprised of three basic categories: ? byte-oriented operations ? bit-oriented operations ? literal and control operations each pic16 instruction is a 14-bit word divided into an opcode, which specifies the instruction type and one or more operands, which further specify the operation of the instruction. the formats for each of the categories is presented in figure 13-1, while the various opcode fields are summarized in table 13-1. table 13-2 lists the instructions recognized by the mpasm tm assembler. for byte-oriented instructions, f represents a file register designator and d represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if d is zero, the result is placed in the w register. if d is one, the result is placed in the file register specified in the instruction. for bit-oriented instructions, b represents a bit field designator, which selects the bit affected by the operation, while f represents the address of the file in which the bit is located. for literal and control operations, k represents an 8-bit or 11-bit constant, or literal value. one instruction cycle consists of four oscillator periods; for an oscillator frequency of 4 mhz, this gives a nominal instruction execution time of 1 s. all instructions are executed within a single instruction cycle, unless a conditional test is true, or the program counter is changed as a result of an instruction. when this occurs, the execution takes two instruction cycles, with the second cycle executed as a nop . all instruction examples use the format 0xhh to represent a hexadecimal number, where h signifies a hexadecimal digit. 13.1 read-modify-write operations any instruction that specifies a file register as part of the instruction performs a read-modify-write (r-m-w) operation. the register is read, the data is modified, and the result is stored according to either the instruction, or the destination designator d. a read operation is performed on a register even if the instruction writes to that register. for example, a clrf porta instruction will read porta, clear all the data bits, then write the result back to porta. this example would have the unintended consequence of clearing the condition that set the raif flag. table 13-1: opcode field descriptions figure 13-1: general format for instructions field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x dont care location (= 0 or 1 ). the assembler will generate code with x = 0 . it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0 : store result in w , d = 1 : store result in file register f. default is d = 1. pc program counter to time-out bit c carry bit dc digit carry bit z zero bit pd power-down bit byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 150 ? 2007 microchip technology inc. table 13-2: pic12f635/pic16f636/639 instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf andwf clrf clrw comf decf decfsz incf incfsz iorwf movf movwf nop rlf rrf subwf swapf xorwf f, d f, d f C f, d f, d f, d f, d f, d f, d f, d f C f, d f, d f, d f, d f, d add w and f and w with f clear f clear w complement f decrement f decrement f, skip if 0 increment f increment f, skip if 0 inclusive or w with f move f move w to f no operation rotate left f through carry rotate right f through carry subtract w from f swap nibbles in f exclusive or w with f 11 1 1 1 1 1 (2) 1 1 (2) 11 1 1 1 1 1 1 1 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01110101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0xxx dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffffffff ffff xxxx ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff c, dc, z zz z z z z z z cc c, dc, z z 1, 2 1, 2 2 1, 2 1, 2 1, 2, 3 1, 2 1, 2, 3 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 bit-oriented file register operations bcf bsf btfsc btfss f, b f, b f, b f, b bit clear f bit set f bit test f, skip if clear bit test f, skip if set 11 1 (2) 1 (2) 0101 01 01 00bb01bb 10bb 11bb bfff bfff bfff bfff ffffffff ffff ffff 1, 2 1, 2 33 literal and control operations addlw andlw call clrwdt goto iorlw movlw retfie retlw return sleep sublw xorlw kk k C kk k C k CC kk add literal and w and literal with w call subroutine clear watchdog timer go to address inclusive or literal with w move literal to w return from interrupt return with literal in w return from subroutine go into standby mode subtract w from literal exclusive or literal with w 11 2 1 2 1 1 2 2 2 1 1 1 1111 10 00 10 11 11 00 11 00 00 11 11 111x1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkkkkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk c, dc, z z to , p d z to , p d c, dc, z z note 1: when an i/o register is modified as a function of itself (e.g., movf gpio, 1 ), the value used will be that value present on the pins themselves. for example, if the data latch is 1 for a pin configured as input and is driven low by an external device, the data will be written back with a 0 . 2: if this instruction is executed on the tm r0 register (and where applicable, d = 1 ), the prescaler will be cleared if assigned to the timer0 module. 3: if the program counter (pc) is modified, or a conditional te st is true, the instruction requires two cycles. the second cycle is executed as a nop . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 151 pic12f635/pic16f636/639 13.2 instruction descriptions addlw add literal and w syntax: [ label ] addlw k operands: 0 k 255 operation: (w) + k (w) status affected: c, dc, z description: the contents of the w register are added to the eight-bit literal k and the result is placed in the w register. addwf add w and f syntax: [ label ] addwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) + (f) (destination) status affected: c, dc, z description: add the contents of the w register with register f. if d is 0 , the result is stored in the w register. if d is 1 , the result is stored back in register f. andlw and literal with w syntax: [ label ] andlw k operands: 0 k 255 operation: (w) .and. (k) (w) status affected: z description: the contents of w register are anded with the eight-bit literal k. the result is placed in the w register. andwf and w with f syntax: [ label ] andwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .and. (f) (destination) status affected: z description: and the w register with register f. if d is 0 , the result is stored in the w register. if d is 1 , the result is stored back in register f. bcf bit clear f syntax: [ label ] bcf f,b operands: 0 f 127 0 b 7 operation: 0 (f) status affected: none description: bit b in register f is cleared. bsf bit set f syntax: [ label ] bsf f,b operands: 0 f 127 0 b 7 operation: 1 (f) status affected: none description: bit b in register f is set. btfsc bit test f, skip if clear syntax: [ label ] btfsc f,b operands: 0 f 127 0 b 7 operation: skip if (f) = 0 status affected: none description: if bit b in register f is 1 , the next instruction is executed. if bit b, in register f, is 0 , the next instruction is discarded, and a nop is executed instead, making this a two-cycle instruction. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 152 ? 2007 microchip technology inc. btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0 f 127 0 b < 7 operation: skip if (f) = 1 status affected: none description: if bit b in register f is 0 , the next instruction is executed. if bit b is 1 , then the next instruction is discarded and a nop is executed instead, making this a two-cycle instruction. call call subroutine syntax: [ label ] call k operands: 0 k 2047 operation: (pc)+ 1 tos, k pc<10:0>, (pclath<4:3>) pc<12:11> status affected: none description: call subroutine. first, return address (pc + 1) is pushed onto the stack. the eleven-bit immediate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruction. clrf clear f syntax: [ label ] clrf f operands: 0 f 127 operation: 00h (f) 1 z status affected: z description: the contents of register f are cleared and the z bit is set. clrw clear w syntax: [ label ] clrw operands: none operation: 00h (w) 1 z status affected: z description: w register is cleared. zero bit (z) is set. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h wdt 0 wdt prescaler, 1 to 1 pd status affected: to , pd description: clrwdt instruction resets the watchdog timer. it also resets the prescaler of the wdt. status bits to and pd are set. comf complement f syntax: [ label ] comf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f ) (destination) status affected: z description: the contents of register f are complemented. if d is 0 , the result is stored in w. if d is 1 , the result is stored back in register f. decf decrement f syntax: [ label ] decf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination) status affected: z description: decrement register f. if d is 0 , the result is stored in the w register. if d is 1 , the result is stored back in register f. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 153 pic12f635/pic16f636/639 decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination); skip if result = 0 status affected: none description: the contents of register f are decremented. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed back in register f. if the result is 1 , the next instruction is executed. if the result is 0 , then a nop is executed instead, making it a two-cycle instruction. goto unconditional branch syntax: [ label ] goto k operands: 0 k 2047 operation: k pc<10:0> pclath<4:3> pc<12:11> status affected: none description: goto is an unconditional branch. the eleven-bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two-cycle instruction. incf increment f syntax: [ label ] incf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination) status affected: z description: the contents of register f are incremented. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed back in register f. incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination), skip if result = 0 status affected: none description: the contents of register f are incremented. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed back in register f. if the result is 1 , the next instruction is executed. if the result is 0 , a nop is executed instead, making it a two-cycle instruction. iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0 k 255 operation: (w) .or. k (w) status affected: z description: the contents of the w register are ored with the eight-bit literal k. the result is placed in the w register. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .or. (f) (destination) status affected: z description: inclusive or the w register with register f. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed back in register f. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 154 ? 2007 microchip technology inc. movf move f syntax: [ label ] movf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) (dest) status affected: z description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0 , destination is w register. if d = 1 , the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example: movf fsr, 0 after instruction w= value in fsr register z= 1 movlw move literal to w syntax: [ label ] movlw k operands: 0 k 255 operation: k (w) status affected: none description: the eight-bit literal k is loaded into w register. the dont cares will assemble as 0 s. words: 1 cycles: 1 example: movlw 0x5a after instruction w= 0x5a movwf move w to f syntax: [ label ] movwf f operands: 0 f 127 operation: (w) (f) status affected: none description: move data from w register to register f. words: 1 cycles: 1 example: movw f option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none description: no operation. words: 1 cycles: 1 example: nop downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 155 pic12f635/pic16f636/639 retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos pc, 1 gie status affected: none description: return from interrupt. stack is poped and top-of-stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example: retfie after interrupt pc = tos gie = 1 retlw return with literal in w syntax: [ label ] retlw k operands: 0 k 255 operation: k (w); tos pc status affected: none description: the w register is loaded with the eight-bit literal k. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example: table call table;w contains table ;offset value ? ;w now has table value ? ? addwf pc ;w = offset retlw k1 ;begin table retlw k2 ; ? ? ? retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8 return return from subroutine syntax: [ label ] return operands: none operation: tos pc status affected: none description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two-cycle instruction. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 156 ? 2007 microchip technology inc. rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register f are rotated one bit to the left through the carry flag. if d is 0 , the result is placed in the w register. if d is 1 , the result is stored back in register f. words: 1 cycles: 1 example: rlf reg1,0 before instruction reg1 = 1110 0110 c= 0 after instruction reg1 = 1110 0110 w = 1100 1100 c= 1 rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register f are rotated one bit to the right through the carry flag. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed back in register f. register f c register f c sleep enter sleep mode syntax: [ label ] sleep operands: none operation: 00h wdt, 0 wdt prescaler, 1 to , 0 pd status affected: to , pd description: the power-down status bit, pd is cleared. time-out status bit, to is set. watchdog timer and its prescaler are cleared. the processor is put into sleep mode with the oscillator stopped. sublw subtract w from literal syntax: [ label ] sublw k operands: 0 k 255 operation: k - (w) ( w) status affected: c, dc, z description: the w register is subtracted (2s complement method) from the eight-bit literal k. the result is placed in the w register. c = 0 w > k c = 1 w k dc = 0 w<3:0> > k<3:0> dc = 1 w<3:0> k<3:0> downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 157 pic12f635/pic16f636/639 subwf subtract w from f syntax: [ label ] subwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - (w) ( destination) status affected: c, dc, z description: subtract (2s complement method) w register from register f. if d is 0 , the result is stored in the w register. if d is 1 , the result is stored back in register f. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f<3:0>) (destination<7:4>), (f<7:4>) (destination<3:0>) status affected: none description: the upper and lower nibbles of register f are exchanged. if d is 0 , the result is placed in the w register. if d is 1 , the result is placed in register f. c = 0 w > f c = 1 w f dc = 0 w<3:0> > f<3:0> dc = 1 w<3:0> f<3:0> xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0 k 255 operation: (w) .xor. k ( w) status affected: z description: the contents of the w register are xored with the eight-bit literal k. the result is placed in the w register. xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .xor. (f) ( destination) status affected: z description: exclusive or the contents of the w register with register f. if d is 0 , the result is stored in the w register. if d is 1 , the result is stored back in register f. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 158 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 159 pic12f635/pic16f636/639 14.0 development support the pic ? microcontrollers are supported with a full range of hardware and software development tools: ? integrated development environment - mplab ? ide software ? assemblers/compilers/linkers - mpasm tm assembler - mplab c18 and mplab c30 c compilers -mplink tm object linker/ mplib tm object librarian - mplab asm30 assembler/linker/library ? simulators - mplab sim software simulator ?emulators - mplab ice 2000 in-circuit emulator - mplab real ice? in-circuit emulator ? in-circuit debugger - mplab icd 2 ? device programmers - picstart ? plus development programmer - mplab pm3 device programmer - pickit? 2 development programmer ? low-cost demonstration and development boards and evaluation kits 14.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16-bit micro- controller market. the mplab ide is a windows ? operating system-based application that contains: ? a single graphical interface to all debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately) ? a full-featured editor with color-coded context ? a multiple project manager ? customizable data windows with direct edit of contents ? high-level source code debugging ? visual device initializer for easy register initialization ? mouse over variable inspection ? drag and drop variables from source to watch windows ? extensive on-line help ? integration of select third party tools, such as hi-tech software c compilers and iar c compilers the mplab ide allows you to: ? edit your source files (either assembly or c) ? one touch assemble (or compile) and download to pic mcu emulator and simulator tools (automatically updates all project information) ? debug using: - source files (assembly or c) - mixed assembly and c - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost-effective simulators, through low-cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increased flexibility and power. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 160 ? 2007 microchip technology inc. 14.2 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for all pic mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include: ? integration into mplab ide projects ? user-defined macros to streamline assembly code ? conditional assembly for multi-purpose source files ? directives that allow complete control over the assembly process 14.3 mplab c18 and mplab c30 c compilers the mplab c18 and mplab c30 code development systems are complete ansi c compilers for microchips pic18 and pic24 families of microcontrol- lers and the dspic30 and dspic33 family of digital sig- nal controllers. these compilers provide powerful integration capabilities, superior code optimization and ease of use not found with other compilers. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 14.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c18 c compiler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: ? efficient linking of single libraries instead of many smaller files ? enhanced code maintainability by grouping related modules together ? flexible creation of libraries with easy module listing, replacement, deletion and extraction 14.5 mplab asm30 assembler, linker and librarian mplab asm30 assembler produces relocatable machine code from symbolic assembly language for dspic30f devices. mplab c30 c compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: ? support for the entire dspic30f instruction set ? support for fixed-point and floating-point data ? command line interface ? rich directive set ? flexible macro language ? mplab ide compatibility 14.6 mplab sim software simulator the mplab sim software simulator allows code development in a pc-hosted environment by simulat- ing the pic mcus and dspic ? dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab sim software simulator fully supports symbolic debugging using the mplab c18 and mplab c30 c compilers, and the mpasm and mplab asm30 assemblers. the software simulator offers the flexibility to develop and debug code outside of the hardware laboratory environment, making it an excellent, economical software development tool. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 161 pic12f635/pic16f636/639 14.7 mplab ice 2000 high-performance in-circuit emulator the mplab ice 2000 in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for pic microcontrollers. software control of the mplab ice 2000 in-circuit emulator is advanced by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator system with enhanced trace, trigger and data monitor- ing features. interchangeable processor modules allow the system to be easily reconfigured for emulation of different processors. the architecture of the mplab ice 2000 in-circuit emulator allows expansion to support new pic microcontrollers. the mplab ice 2000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft ? windows ? 32-bit operating system were chosen to best make these features available in a simple, unified application. 14.8 mplab real ice in-circuit emulator system mplab real ice in-circuit emulator system is microchips next generation high-speed emulator for microchip flash dsc ? and mcu devices. it debugs and programs pic ? and dspic ? flash microcontrollers with the easy-to-use, powerful graphical user interface of the mplab integrated development environment (ide), included with each kit. the mplab real ice probe is connected to the design engineers pc using a high-speed usb 2.0 interface and is connected to the target with either a connector compatible with the popular mplab icd 2 system (rj11) or with the new high speed, noise tolerant, low- voltage differential signal (lvds) interconnection (cat5). mplab real ice is field upgradeable through future firmware downloads in mplab ide. in upcoming releases of mplab ide, new devices will be supported, and new features will be added, such as software break- points and assembly code trace. mplab real ice offers significant advantages over competitive emulators including low-cost, full-speed emulation, real-time variable watches, trace analysis, complex breakpoints, a ruggedized probe interface and long (up to three meters) interconnection cables. 14.9 mplab icd 2 in-circuit debugger microchips in-circuit debugger, mplab icd 2, is a powerful, low-cost, run-time development tool, connecting to the host pc via an rs-232 or high-speed usb interface. this tool is based on the flash pic mcus and can be used to develop for these and other pic mcus and dspic dscs. the mplab icd 2 utilizes the in-circuit debugging capability built into the flash devices. this feature, along with microchips in-circuit serial programming tm (icsp tm ) protocol, offers cost- effective, in-circuit flash debugging from the graphical user interface of the mplab integrated development environment. this enables a designer to develop and debug source code by setting breakpoints, single step- ping and watching variables, and cpu status and peripheral registers. running at full speed enables testing hardware and applications in real time. mplab icd 2 also serves as a development programmer for selected pic devices. 14.10 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages and a modu- lar, detachable socket assembly to support various package types. the icsp? cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program pic devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices and incorporates an sd/mmc card for file storage and secure data applications. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 162 ? 2007 microchip technology inc. 14.11 picstart plus development programmer the picstart plus development programmer is an easy-to-use, low-cost, prototype programmer. it connects to the pc via a com (rs-232) port. mplab integrated development environment software makes using the programmer simple and efficient. the picstart plus development programmer supports most pic devices in dip packages up to 40 pins. larger pin count devices, such as the pic16c92x and pic17c76x, may be supported with an adapter socket. the picstart plus development programmer is ce compliant. 14.12 pickit 2 development programmer the pickit? 2 development programmer is a low-cost programmer and selected flash device debugger with an easy-to-use interface for programming many of microchips baseline, mid-range and pic18f families of flash memory microcontrollers. the pickit 2 starter kit includes a prototyping development board, twelve sequential lessons, software and hi-techs picc? lite c compiler, and is designed to help get up to speed quickly using pic ? microcontrollers. the kit provides everything needed to program, evaluate and develop applications using microchips powerful, mid-range flash memory family of microcontrollers. 14.13 demonstration, development and evaluation boards a wide variety of demonstration, development and evaluation boards for various pic mcus and dspic dscs allows quick application development on fully func- tional systems. most boards include prototyping areas for adding custom circuitry and provide application firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demon- stration/development board series of circuits, microchip has a line of evaluation kits and demonstration software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart ? battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. check the microchip web page (www.microchip.com) and the latest product selector guide (ds00148) for the complete list of demonstration, development and evaluation kits. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 163 pic12f635/pic16f636/639 15.0 electrical specifications absolute maximum ratings (?) ambient temperature under bias................................................................................................. ...... -40c to +125c storage temperature ............................................................................................................ ............ -65c to +150c voltage on v dd with respect to v ss ................................................................................................... -0.3v to +6.5v voltage on mclr with respect to vss ............................................................................................... -0.3v to +1 3.5v voltage on all other pins with respect to v ss ........................................................................... -0.3v to (v dd + 0.3v) total power dissipation (1) ............................................................................................................................... 800 mw maximum current out of v ss /v sst pin .............................................................................................................. 95 ma maximum current into v dd /v ddt pin ................................................................................................................. 95 ma input clamp current, i ik (v i < 0 or v i > v dd ) ............................................................................................................... 20 ma output clamp current, iok (v o < 0 or v o >v dd ) ....................................................................................................... 20 ma maximum output current sunk by any i/o pin..................................................................................... ............... 25 ma maximum output current sourced by any i/o pin .................................................................................. ............ 25 ma maximum current sunk by porta and portc (combined) ............................................................................ 9 5 ma maximum current sourced porta and portc (combined) ............................................................................ 9 5 ma maximum lc input voltage (lcx, lcy, lcz) (2) loaded, with device ............................................................ 10.0 v pp maximum lc input voltage (lcx, lcy, lcz) (2) unloaded, without device ................................................. 700.0 v pp maximum input current (rms) into device per lc channel (2) ........................................................................... 10 ma human body esd rating .......................................................................................................... .............. 4000 (min.) v machine model esd rating ....................................................................................................... ............... 400 (min.) v note 1: power dissipation for pic12f635/pic16f636/639 (afe section not included) is calculated as follows: p dis = v dd x {i dd - i oh } + {(v dd -v oh ) x i oh } + (v ol x i ol ). power dissipation for afe section is calculated as follows: p dis = v dd x i act = 3.6v x 16 a = 57.6 w 2: specification applies to the pic16f639 only. ? notice: stresses above those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only and functional operation of the devi ce at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. note: voltage spikes below v ss at the mclr pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resistor of 50-100 should be used when applying a low level to the mclr pin, rather than pulling this pin directly to v ss . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 164 ? 2007 microchip technology inc. figure 15-1: pic12f635/16f636 voltage-frequency graph, -40c t a +125c figure 15-2: pic16f639 voltage-frequency graph, -40c t a +85c 5.5 2.0 3.5 2.5 0 3.0 4.0 4.5 5.0 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: cross-hatched area is for hfintosc and ec modes only. 82 0 10 4 5.5 2.0 3.6 2.5 0 3.0 4.0 4.5 5.0 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: cross-hatched area is for hfintosc and ec modes only. 82 0 10 4 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 165 pic12f635/pic16f636/639 figure 15-3: hfintosc frequency accuracy over device v dd and temperature 125 25 2.0 0 60 85 v dd (v) 4.0 5.0 4.5 temperature ( c ) 2.5 3.0 3.5 5.5 1% 2% 5% -40 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 166 ? 2007 microchip technology inc. 15.1 dc characteristics: pic12f635/pic16f636-i (industrial) pic12f635/pic16f636-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym characteristic min typ? max units conditions d001 d001a d001b d001c v dd supply voltage 2.02.0 3.0 4.5 5.5 5.5 5.5 5.5 vv v v f osc < = 4 mhz f osc < = 8 mhz, hfintosc, ec f osc < = 10 mhz f osc < = 20 mhz d002 v dr ram data retention voltage (1) 1.5* v device in sleep mode d003 v por v dd start voltage to ensure internal power-on reset signal v ss vs e e section 12.3 power-on reset for details. d004 s vdd v dd rise rate to ensure internal power-on reset signal 0.05* v/ms see section 12.3 power-on reset for details. d005 v bod brown-out reset 2.0 2.1 2.2 v * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 167 pic12f635/pic16f636/639 15.2 dc characteristics: pic12f635/pic16f636-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial param no. sym device characteristics min typ? max units conditions v dd note d010 i dd supply current (1,2) 1 1 1 6 a2 . 0f osc = 32.768 khz lp oscillator mode 1 8 2 8 a3 . 0 3 5 5 4 a5 . 0 d011 140 240 a2 . 0f osc = 1 mhz xt oscillator mode 2 2 03 8 0 a3 . 0 3 8 05 5 0 a5 . 0 d012 260 360 a2 . 0f osc = 4 mhz xt oscillator mode 4 2 06 5 0 a3 . 0 0.8 1.1 ma 5.0 d013 130 220 a2 . 0f osc = 1 mhz ec oscillator mode 2 1 53 6 0 a3 . 0 3 6 05 2 0 a5 . 0 d014 220 340 a2 . 0f osc = 4 mhz ec oscillator mode 3 7 55 5 0 a3 . 0 0.65 1.0 ma 5.0 d015 8 20 a2 . 0f osc = 31 khz lfintosc mode 1 6 4 0 a3 . 0 3 1 6 5 a5 . 0 d016 340 450 a2 . 0f osc = 4 mhz hfintosc mode 5 0 07 0 0 a3 . 0 0.8 1.2 ma 5.0 d017 410 650 a2 . 0f osc = 8 mhz hfintosc mode 7 0 09 5 0 a3 . 0 1.30 1.65 ma 5.0 d018 230 400 a2 . 0f osc = 4 mhz extrc mode 4 0 06 8 0 a3 . 0 0.63 1.1 ma 5.0 d019 2.6 3.25 ma 4.5 f osc = 20 mhz hs oscillator mode 2.6 3.25 ma 5.0 ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. mcu only, analog front-end not included. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current consumption. mcu only, analog front-end not included. 3: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 4: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 168 ? 2007 microchip technology inc. d020 i pd power-down base current (4) 0 . 1 51 . 2 a 2.0 wdt, bor, comparators, v ref and t1osc disabled 0 . 2 01 . 5 a3 . 0 0.35 1.8 a5 . 0 d021 1.0 2.2 a 2.0 wdt current (1) 2 . 04 . 0 a3 . 0 3 . 07 . 0 a5 . 0 d022a 58 60 a 3.0 bor current (1) 1 0 91 2 2 a5 . 0 d022b 22 28 a 2.0 plvd current 2 5 3 5 a3 . 0 3 3 4 5 a5 . 0 d023 32 45 a 2.0 comparator current (3) 6 0 7 8 a3 . 0 1 2 01 6 0 a5 . 0 d024a 30 36 a2 . 0c v ref current (1) (high-range) 4 5 5 5 a3 . 0 7 5 9 5 a5 . 0 d024b 39 47 a2 . 0c v ref current (1) (low-range) 5 9 7 2 a3 . 0 9 81 2 4 a5 . 0 d025 4.5 7.0 a 2.0 t1osc current (3) 5 . 08 . 0 a3 . 0 6 . 0 1 2 a5 . 0 15.2 dc characteristics: pic12f635/pic16f636-i (industrial) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial param no. sym device characteristics min typ? max units conditions v dd note ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. mcu only, analog front-end not included. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current consumption. mcu only, analog front-end not included. 3: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 4: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 169 pic12f635/pic16f636/639 15.3 dc characteristics: pic12f635/pic16f636-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended param no. sym device characteristics min typ? max units conditions v dd note d010e i dd supply current (1,2) 1 11 6 a2 . 0f osc = 32.768 khz lp oscillator mode 1 82 8 a3 . 0 3 55 4 a5 . 0 d011e 140 240 a2 . 0f osc = 1 mhz xt oscillator mode 220 380 a3 . 0 380 550 a5 . 0 d012e 260 360 a2 . 0f osc = 4 mhz xt oscillator mode 420 650 a3 . 0 0.8 1.1 ma 5.0 d013e 130 220 a2 . 0f osc = 1 mhz ec oscillator mode 215 360 a3 . 0 360 520 a5 . 0 d014e 220 340 a2 . 0f osc = 4 mhz ec oscillator mode 375 550 a3 . 0 0.65 1.0 ma 5.0 d015e 82 0 a2 . 0f osc = 31 khz lfintosc mode 16 40 a3 . 0 31 65 a5 . 0 d016e 340 450 a2 . 0f osc = 4 mhz hfintosc mode 500 700 a3 . 0 0.8 1.2 ma 5.0 d017e 410 650 a2 . 0 f osc = 8 mhz hfintosc mode 700 950 a3 . 0 1.30 1.65 ma 5.0 d018e 230 100 a2 . 0f osc = 4 mhz extrc mode 400 680 a3 . 0 0.63 1.1 ma 5.0 d019e 2.6 3.25 ma 4.5 f osc = 20 mhz hs oscillator mode 2.8 3.35 ma 5.0 ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external squar e wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and fr equency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pattern and tem perature, also have an impact on the current consumption. 3: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this periph- eral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 4: the power-down current in sleep mode does not depend on the oscillator type. power-d own current is measured with the part in sleep mode, with all i/o pins in high-impedance s tate and tied to v dd . downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 170 ? 2007 microchip technology inc. d020 i pd power-down base current (4) 0.15 1.2 a 2.0 wdt, bor, comparators, v ref and t1osc disabled 0.20 1.5 a3 . 0 0.35 1.8 a5 . 0 d021 1.0 17.5 a 2.0 wdt current (1) 2 . 01 9 a3 . 0 3 . 02 2 a5 . 0 d022a 42 60 a 3.0 bor current (1) 8 51 2 2 a5 . 0 d022b 22 48 a2 . 0p l v d c u r r e n t 2 55 5 a3 . 0 3 36 5 a5 . 0 d023 32.3 45 a 2.0 comparator current (1) 6 07 8 a3 . 0 120 160 a5 . 0 d024a 30 36 a2 . 0c v ref current (1) (high-range) 4 55 5 a3 . 0 7 59 5 a5 . 0 d024b 39 47 a2 . 0c v ref current (1) (low-range) 5 97 2 a3 . 0 9 81 2 4 a5 . 0 d025 4.5 25 a 2.0 t1osc current (3) 5 . 03 0 a3 . 0 6 . 04 0 a5 . 0 15.3 dc characteristics: pic12f635/pic16f636-e (extended) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended param no. sym device characteristics min typ? max units conditions v dd note ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external squar e wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and fr equency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pattern a nd temperature, also have an impact on the current consumption. 3: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this periph- eral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 4: the power-down current in sleep mode does not depend on the oscillator type. power-d own current is measured with the part in sleep mode, with all i/o pins in high-impedance s tate and tied to v dd . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 171 pic12f635/pic16f636/639 15.4 dc characteristics: pic12f635/pic16f636-i (industrial) pic12f635/pic16f636-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym characteristic min typ? max units conditions v il input low voltage i/o ports: d030 with ttl buffer v ss 0.8 v 4.5v v dd 5.5v d030a v ss 0.15 v dd votherwise d031 with schmitt trigger buffer v ss 0.2 v dd v entire range d032 mclr , osc1 (rc mode) v ss 0.2 v dd v d033 osc1 (xt and lp modes) (1) v ss 0 . 3v d033a osc1 (hs mode) (1) v ss 0.3 v dd v v ih input high voltage i/o ports: d040 d040a with ttl buffer 2.0 (0.25 v dd + 0.8) v dd v dd vv 4.5v v dd 5.5v otherwise d041 with schmitt trigger buffer 0.8 v dd v dd v entire range d042 mclr 0.8 v dd v dd v d043 osc1 (xt and lp modes) 1.6 v dd v (note 1) d043a osc1 (hs mode) 0.7 v dd v dd v (note 1) d043b osc1 (rc mode) 0.9 v dd v dd v i il input leakage current (2) d060 i/o ports 0 . 1 1 av ss v pin v dd , pin at high-impedance d060a analog inputs 0 . 1 1 av ss v pin v dd d060b v ref 0 . 1 1 av ss v pin v dd d061 mclr (3) 0 . 1 5 av ss v pin v dd d063 osc1 0 . 1 5 av ss v pin v dd , xt, hs and lp oscillator configuration d070 i pur porta weak pull-up current 50 250 400 av dd = 5.0v, v pin = v ss d071 i pdr porta weak pull-down current 50 250 400 av dd = 5.0v, v pin = v dd v ol output low voltage d080 i/o ports 0.6 v i ol = 8.5 ma, v dd = 4.5v (ind.) d083 osc2/clkout (rc mode) 0.6 v i ol = 1.6 ma, v dd = 4.5v (ind.) i ol = 1.2 ma, v dd = 4.5v (ext.) * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger i nput. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: see section 9.4.1 using the data eeprom for additional information. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 172 ? 2007 microchip technology inc. v oh output high voltage d090 i/o ports v dd C 0.7 v i oh = -3.0 ma, v dd = 4.5v (ind.) d092 osc2/clkout (rc mode) v dd C 0.7 v i oh = -1.3 ma, v dd = 4.5v (ind.) i oh = -1.0 ma, v dd = 4.5v (ext.) d100 i ulp ultra low-power wake-up current 2 0 0n a capacitive loading specs on output pins d101 cosc2 osc2 pin 15* pf in xt, hs and lp modes when external clock is used to drive osc1 d101a c io all i/o pins 50* pf data eeprom memory d120 e d byte endurance 100k 1m e/w -40 c t a +85c d120a e d byte endurance 10k 100k e/w +85c t a +125c d121 v drw v dd for read/write v min 5.5 v using eecon1 to read/write v min = minimum operating voltage d122 t dew erase/write cycle time 5 6 ms d123 t retd characteristic retention 40 year provided no other specifications are violated d124 t ref number of total erase/write cycles before refresh (4) 1m 10m e/w -40 c t a +85c program flash memory d130 e p cell endurance 10k 100k e/w -40 c t a +85c d130a e d cell endurance 1k 10k e/w +85c t a +125c d131 v pr v dd for read v min 5 . 5vv min = minimum operating voltage d132 v pew v dd for erase/write 4.5 5.5 v d133 t pew erase/write cycle time 2 2.5 ms d134 t retd characteristic retention 40 year provided no other specifications are violated 15.4 dc characteristics: pic12f635/pic16f636-i (industrial) pic12f635/pic16f636-e (extended) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym characteristic min typ? max units conditions * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigge r input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: see section 9.4.1 using the data eeprom for additional information. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 173 pic12f635/pic16f636/639 15.5 dc characteristics: pic16f639-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial param no. sym characteristic min typ? max units conditions d001 v dd supply voltage 2.0 3.6 v f osc 10 mhz d001a v ddt supply voltage (afe) 2.0 3.6 v analog front-end v dd voltage. treated as v dd in this document. d002 v dr ram data retention voltage (1) 1.5* v device in sleep mode d003 v por v dd start voltage to ensure internal power-on reset signal v ss vs e e section 12.3 power-on reset for details. d003a v port v dd start voltage (afe) to ensure internal power- on reset signal 1.8 v analog front-end por voltage. d004 s vdd v dd rise rate to ensure internal power-on reset signal 0.05* v/ms see section 12.3 power-on reset for details. d005 v bod brown-out reset 2.0 2.1 2.2 v d006 r m turn-on resistance or modulation transistor 50 100 ohm v dd = 3.0v d007 r pu digital input pull-up resistor cs , sclk 50 200 350 kohm v dd = 3.6v d008 i ail analog input leakage current lcx, lcy, lcz lccom 11 a a v dd = 3.6v, v ss v in v dd , tested at sleep mode * these parameters are characterized but not tested. ? data in typ column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 174 ? 2007 microchip technology inc. 15.6 dc characteristics: pic16f639-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial supply voltage 2.0v v dd 3.6v param no. sym device characteristics min typ? max units conditions v dd note d010 i dd supply current (1,2,3) 1 11 6 a2 . 0f osc = 32.768 khz lp oscillator mode 1 82 8 a3 . 0 d011 140 240 a2 . 0f osc = 1 mhz xt oscillator mode 220 380 a3 . 0 d012 260 360 a2 . 0f osc = 4 mhz xt oscillator mode 420 650 a3 . 0 d013 130 220 a2 . 0f osc = 1 mhz ec oscillator mode 215 360 a3 . 0 d014 220 340 a2 . 0f osc = 4 mhz ec oscillator mode 375 550 a3 . 0 d015 8 20 a2 . 0f osc = 31 khz lfintosc mode 1 64 0 a3 . 0 d016 340 450 a2 . 0f osc = 4 mhz hfintosc mode 500 700 a3 . 0 d017 230 400 a2 . 0f osc = 4 mhz extrc mode 400 680 a3 . 0 d020 i pd power-down base current (4) 0.15 1.2 a 2.0 wdt, bor, comparators, v ref and t1osc disabled (excludes afe) 0.20 1.5 a3 . 0 d021 iwdt 1.2 2.2 a2 . 0w d t c u r r e n t (1) 2 . 04 . 0 a3 . 0 d022a ibor 42 60 a 3.0 bor current (1) d022b ilvd 22 28 a 2.0 plvd current 2 53 5 a3 . 0 d023 icmp 32 45 a 2.0 comparator current (1) 6 07 8 a3 . 0 d024a iv refhs 3 03 6 a2 . 0c v ref current (1) (high-range) 4 55 5 a3 . 0 d024b iv refls 3 94 7 a2 . 0c v ref current (1) (low-range) 5 97 2 a3 . 0 d025 it1osc 4.5 7.0 a 2.0 t1osc current (1) 5 . 08 . 0 a3 . 0 d026 i act active current of afe only (receiving signal) 1 lc input channel signal 3 lc input channel signals 1013 18 a a 3.6 3.6 cs = v dd ; input = continuous wave (cw); amplitude = 300 mv pp . all channels enabled. d027 i stdby standby current of afe only (not receiving signal) 1 lc input channel enabled 2 lc input channels enabled 3 lc input channels enabled 34 5 56 7 a a 3.6 3.6 3.6 cs = v dd ; alert = v dd d028 i sleep sleep current of afe only 0.2 1 a3 . 6c s = v dd ; alert = v dd ? data in typ column is at 3.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. mcu only, analog front-end not included. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and swit ching rate, oscillator type, internal code execution pattern and temperature, also ha ve an impact on the current consumption. mcu only, ana log front-end not included. 3: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 4: the power-down current in sleep mode does not depend on the oscillator typ e. power-down current is measured with the part in sl eep mode, with all i/o pins in high-impedance state and tied to v dd . downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 175 pic12f635/pic16f636/639 15.7 dc characteristics: pic16f639-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial supply voltage 2.0v v dd 3.6v param no. sym characteristic min typ? max units conditions v il input low voltage i/o ports: d030a with ttl buffer v ss 0.15 v dd v d031 with schmitt trigger buffer v ss 0 . 2 v dd v d032 mclr , osc1 (rc mode) v ss 0 . 2 v dd v d033 osc1 (xt and lp modes) (1) v ss 0 . 3v d033a osc1 (hs mode) (1) v ss 0 . 3 v dd v d034 digital input low voltage v ss 0 . 3 v dd v analog front-end section v ih input high voltage i/o ports: d040 with ttl buffer d040a (0.25 v dd + 0.8) v dd v d041 with schmitt trigger buffer 0.8 v dd v dd v d042 mclr 0.8 v dd v dd v d043 osc1 (xt and lp modes) 1.6 v dd v (note 1) d043a osc1 (hs mode) 0.7 v dd v dd v (note 1) d043b osc1 (rc mode) 0.9 v dd v dd v digital input high voltage analog front-end section d044 sclk, cs , sdio for analog front-end (afe) 0.8 v dd v dd v i il input leakage current (2) d060 i/o ports 0 . 1 1 av ss v pin v dd , pin at high-impedance d060a analog inputs 0 . 1 1 av ss v pin v dd d060b v ref 0 . 1 1 av ss v pin v dd d061 mclr (3) 0 . 1 5 av ss v pin v dd d063 osc1 0 . 1 5 av ss v pin v dd , xt, hs and lp oscillator configuration digital input leakage current (2) v dd = 3.6v, analog front-end section d064 sdi for analog front-end (afe) 1 av ss v pin v dd d064a sclk, cs for analog front-end (afe) 1 av pin v dd d070 i pur porta weak pull-up current 50* 250 400 av dd = 3.6v, v pin = v ss d071 i pdr porta weak pull-down current 50 250 400 av dd = 3.6v, v pin = v dd v ol output low voltage d080 i/o ports 0.6 v i ol = 8.5 ma, v dd = 3.6v (ind.) d083 osc2/clkout (rc mode) 0.6 v i ol = 1.6 ma, v dd = 3.6v (ind.) i ol = 1.2 ma, v dd = 3.6v (ext.) digital output low voltage analog front-end section d084 alert , lfdata/sdio for analog front-end (afe) v ss + 0.4 vi ol = 1.0 ma, v dd = 2.0v * these parameters are characterized but not tested. ? data in typ column is at 3.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recomme nded to use an external clock i n rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal opera ting conditions. higher leakage current may be measured at different input voltages. 4: see section 9.4.1 using the data eeprom for additional information downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 176 ? 2007 microchip technology inc. v oh output high voltage d090 i/o ports v dd C 0.7 v i oh = -3.0 ma, v dd = 3.6v (ind.) d092 osc2/clkout (rc mode) v dd C 0.7 v i oh = -1.3 ma, v dd = 3.6v (ind.) i oh = -1.0 ma, v dd = 3.6v (ext.) digital output high voltage analog front-end (afe) section d093 lfdata/sdio for analog front-end (afe) v dd C 0.5 v i oh = -400 a, v dd = 2.0v capacitive loading specs on output pins d100 cosc2 osc2 pin 15* pf in xt, hs and lp modes when external clock is used to drive osc1 d101 c io all i/o pins 50* pf d102 i ulp ultra low-power wake-up current 2 0 0n a data eeprom memory d120 e d byte endurance 100k 1m e/w -40 c t a +85c d120a e d byte endurance 10k 100k e/w +85c t a +125c d121 v drw v dd for read/write v min 5.5 v using eecon1 to read/write v min = minimum operating voltage d122 t dew erase/write cycle time 5 6 ms d123 t retd characteristic retention 40 year provided no other specifications are violated d124 t ref number of total erase/write cycles before refresh (1) 1m 10m e/w -40 c t a +85c program flash memory d130 e p cell endurance 10k 100k e/w -40 c t a +85c d130a e d cell endurance 1k 10k e/w +85c t a +125c d131 v pr v dd for read v min 5 . 5vv min = minimum operating voltage d132 v pew v dd for erase/write 4.5 5.5 v d133 t pew erase/write cycle time 2 2.5 ms d134 t retd characteristic retention 40 year provided no other specifications are violated 15.7 dc characteristics: pic16f639-i (industrial) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial supply voltage 2.0v v dd 3.6v param no. sym characteristic min typ? max units conditions * these parameters are characterized but not tested. ? data in typ column is at 3.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recomme nded to use an external clock i n rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal opera ting conditions. higher leakage current may be measured at different input voltages. 4: see section 9.4.1 using the data eeprom for additional information downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 177 pic12f635/pic16f636/639 15.8 thermal considerations standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c para m no. sym characteristic typ units conditions th01 ja thermal resistance junction to ambient pic12f635 84.6 c/w 8-pin pdip package 163.0 c/w 8-pin soic package 52.4 c/w 8-pin dfn 4x4x0.9 mm package 52.4 c/w 8-pin dfn-s 6x5 mm package pic16f636 69.8 c/w 14-pin pdip package 85.0 c/w 14-pin soic package 100.4 c/w 14-pin tssop package 46.3 c/w 16-pin qfn 4x0.9mm package pic16f639 108.1 c/w 20-pin ssop package th02 jc thermal resistance junction to case pic12f635 41.2 c/w 8-pin pdip package 38.8 c/w 8-pin soic package 3.0 c/w 8-pin dfn 4x4x0.9 mm package 3.0 c/w 8-pin dfn-s 6x5 mm package pic16f636 32.5 c/w 14-pin pdip package 31.0 c/w 14-pin soic package 31.7 c/w 14-pin tssop package 2.6 c/w 16-pin qfn 4x0.9mm package pic16f639 32.2 c/w 20-pin ssop package th03 t j junction temperature 150 c for derated power calculations th04 pd power dissipation w pd = p internal + p i / o th05 p internal internal power dissipation w p internal = i dd x v dd (note 1) th06 p i / o i/o power dissipation w p i / o = (i ol * v ol ) + (i oh * (v dd - v oh )) th07 p der derated power w p der = (t j - t a )/ ja (note 2, 3) note 1: i dd is current to run the chip alone without driving any load on the output pins. 2: t a = ambient temperature. 3: maximum allowable power dissipation is the lower value of either the absolute maximum total powe r dissipation or derated power (p der ). downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 178 ? 2007 microchip technology inc. 15.9 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 15-4: load conditions 1. tpps2pps 2. tpps t f frequency t time lowercase letters (pp) and their meanings: pp cc ccp1 osc osc1 ck clkout rd rd cs cs rw rd or wr di sdi sc sclk do sdo ss ss dt data in t0 t0cki io i/o port t1 t1cki mc mclr wr wr uppercase letters and their meanings: s ff a l l pp e r i o d hh i g h rr i s e i invalid (high-impedance) v valid l low z high-impedance v ss c l legend: c l = 50 pf for all pins 15 pf for osc2 output load condition pin downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 179 pic12f635/pic16f636/639 15.10 ac characteristics: pic12f635/pic16f636/639 (industrial, extended) figure 15-5: clock timing table 15-1: clock oscillator timing requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristic min typ? max units conditions os01 f osc external clkin frequency (1) dc 37 khz lp oscillator mode dc 4 mhz xt oscillator mode dc 20 mhz hs oscillator mode dc 20 mhz ec oscillator mode oscillator frequency (1) 32.768 khz lp oscillator mode 0.1 4 mhz xt oscillator mode 1 20 mhz hs oscillator mode dc 4 mhz rc oscillator mode os02 t osc external clkin period (1) 27 s lp oscillator mode 250 ns xt oscillator mode 50 ns hs oscillator mode 50 ns ec oscillator mode oscillator period (1) 3 0 . 5 s lp oscillator mode 250 10,000 ns xt oscillator mode 50 1,000 ns hs oscillator mode 250 ns rc oscillator mode os03 t cy instruction cycle time (1) 200 t cy dc ns t cy = 4/f osc os04* tosh, tos l external clkin high, external clkin low 2 s lp oscillator 100 ns xt oscillator 20 ns hs oscillator os05* tosr, tos f external clkin rise, external clkin fall 0 50 ns lp oscillator 0 25 ns xt oscillator 0 15 ns hs oscillator * these parameters are characterized but not tested. ? data in typ column is at 5v, 25c unless otherwise stated. these parameters ar e for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in a n unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at min values wi th an external clock applied to osc1 pin. when an external clock input is used, the max cyc le time limit is dc (no clock) for all devices. osc1/clkin osc2/clkout q4 q1 q2 q3 q4 q1 os02 os03 os04 os04 osc2/clkout (lp, xt, hs modes) (clkout mode) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 180 ? 2007 microchip technology inc. table 15-2: oscillator parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristic freq tolerance min typ? max units conditions os06 t warm internal oscillator switch when running (3) 2t osc slowest clock os07 t sc fail-safe sample clock period (1) 21 ms lfintosc/64 os08 hf osc internal calibrated hfintosc frequency (2) 1% 7.92 8.0 8.08 mhz v dd = 3.5v, 25c 2% 7.84 8.0 8.16 mhz 2.5v v dd 5.5v, 0c t a +85c 5% 7.60 8.0 8.40 mhz 2.0v v dd 5.5v, -40c t a +85c (ind.), -40c t a +125c (ext.) os09* lf osc internal uncalibrated lfintosc frequency 1 53 14 5k h z os10* t ioscst hfintosc oscillator wake-up from sleep start-up time 5.5 12 24 sv dd = 2.0v, -40c to +85c 3 . 571 4 sv dd = 3.0v, -40c to +85c 361 1 sv dd = 5.0v, -40c to +85c * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25c unless otherwise stated. these para meters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values a re based on characterization data for that particular oscillator type u nder standard operating conditions with the device executing code. exceeding these specified limits may result in an unstabl e oscillator operation and/or higher than expected current consumption. all devices are tested to operate at min values with an external clock applied to the osc1 pin. when an external clock input is used, the max cycle time l imit is dc (no clock) for all devices. 2: to ensure these oscillator frequency tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended. 3: by design. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 181 pic12f635/pic16f636/639 figure 15-6: clkout and i/o timing f osc clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 os11 os19 os13 os15 os18, os19 os20 os21 os17 os16 os14 os12 os18 old value new value write fetch read execute cycle table 15-3: clkout and i/o timing parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristic min typ? max units conditions os11 t os h2 ck lf osc to clkout (1) 70 ns v dd = 5.0v os12 t os h2 ck hf osc to clkout (1) 72 ns v dd = 5.0v os13 t ck l2 io vclkout to port out valid (1) 20 ns os14 t io v2 ck h port input valid before clkout (1) t osc + 200 ns ns os15* t os h2 io vf osc (q1 cycle) to port out valid 50 70 ns v dd = 5.0v os16 t os h2 io if osc (q2 cycle) to port input invalid (i/o in hold time) 50 ns v dd = 5.0v os17 t io v2 os h port input valid to f osc (q2 cycle) (i/o in setup time) 20 ns os18 t io r port output rise time (2) 4015 7232 ns v dd = 2.0v v dd = 5.0v os19 t io f port output fall time (2) 2815 5530 ns v dd = 2.0v v dd = 5.0v os20* t inp int pin input high or low time 25 ns os21* t rap porta interrupt-on-change new input level time t cy n s * these parameters are characterized but not tested. ? data in typ column is at 5.0v, 25 c unless otherwise stated. note 1: measurements are taken in rc mode where clkout output is 4 x t osc . 2: includes osc2 in clkout mode. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 182 ? 2007 microchip technology inc. figure 15-7: reset, watchdog timer, oscillator start-up timer and power-up timer timing figure 15-8: brown-out rese t timing and characteristics v dd mclr internal por pwrt time-out osc start-up time internal reset (1) watchdog timer 33 32 30 31 34 i/o pins 34 note 1: asserted low. reset (1) v bor v dd (device in brown-out reset) (device not in brown-out reset) 33* 37 * 64 ms delay only if pwrte bit in the configuration word register is programmed to 0 . reset (due to bor) v bor + v hyst downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 183 pic12f635/pic16f636/639 table 15-4: reset, watchdog timer, oscillator start-up timer, power-up timer and brown-out reset parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristic min typ? max units conditions 30 t mc lmclr pulse width (low) 2 5 s s v dd = 5v, -40c to +85c v dd = 5v 31 t wdt watchdog timer time-out period (no prescaler) 1010 1616 2931 msms v dd = 5v, -40c to +85c v dd = 5v 32 t ost oscillation start-up timer period (1, 2) 1024 t osc (note 3) 33* t pwrt power-up timer period 40 65 140 ms 34* t ioz i/o high-impedance from mclr low or watchdog timer reset 2 . 0 s 35 v bor brown-out reset voltage 2.0 2.2 v (note 4) 36* v hyst brown-out reset hysteresis 50 mv 37* t bor brown-out reset minimum detection period 100 sv dd v bor * these parameters are characterized but not tested. ? data in typ column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillato r oper- ation and/or higher than expected current consumption. all devices are tested to operate at min values with an external clock applied to the osc1 pin. when an external clock input is used, the max cycle time limit is dc (no clock) for all devices. 2: by design. 3: period of the slower clock. 4: to ensure these voltage tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 184 ? 2007 microchip technology inc. figure 15-9: timer0 and timer1 external clock timings table 15-5: timer0 and timer1 external clock requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristic min typ? max units conditions 40* t t 0h t0cki high pulse width no prescaler 0.5 t cy + 20 ns with prescaler 10 ns 41* t t 0l t0cki low pulse width no prescaler 0.5 t cy + 20 ns with prescaler 10 ns 42* t t 0p t0cki period greater of: 20 or t cy + 40 n ns n = prescale value (2, 4, ..., 256) 45* t t 1h t1cki high time synchronous, no prescaler 0.5 t cy + 20 ns synchronous, with prescaler 15 ns asynchronous 30 ns 46* t t 1l t1cki low time synchronous, no prescaler 0.5 t cy + 20 ns synchronous, with prescaler 15 ns asynchronous 30 ns 47* t t 1p t1cki input period synchronous greater of: 30 or t cy + 40 n ns n = prescale value (1, 2, 4, 8) asynchronous 60 ns 48 f t 1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) 32.768 khz 49* tckez tmr 1 delay from external clock edge to timer increment 2 t osc 7 t osc timers in sync mode * these parameters are characterized but not tested. ? data in typ column is at 5v, 25c unless otherwise stat ed. these parameters are for design guidance only and are not tested. t0cki t1cki 40 41 42 45 46 47 49 tmr0 or tmr1 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 185 pic12f635/pic16f636/639 table 15-6: comparator specifications table 15-7: comparator voltage reference (cv ref ) specifications table 15-8: pic12f635/pic16f636 plvd characteristics : standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristics min typ? max units comments cm01 v os input offset voltage 5.0 10 mv (v dd - 1.5)/2 cm02 v cm input common mode voltage 0 v dd C 1.5 v cm03* c mrr common mode rejection ratio +55 db cm04* t rt response time falling 150 600 ns (note 1) rising 200 1000 ns cm05* t mc 2 co v comparator mode change to output valid 1 0 s * these parameters are characterized but not tested. ? data in typ column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: response time is measured with one comparator input at (v dd -1.5)/2-100mv to (v dd - 1.5)/2 + 20 mv. standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym characteristics min typ? max units comments cv01* c lsb step size (2) v dd /24 v dd /32 vv low range (vrr = 1 ) high range (vrr = 0 ) cv02* c acc absolute accuracy 1/2 1/2 lsb lsb low range (vrr = 1 ) high range (vrr = 0 ) cv03* c r unit resistor value (r) 2k cv04* c st settling time (1) 1 0 s * these parameters are characterized but not tested. ? data in typ column is at 5v, 25c unless otherwise stated. these parame ters are for design guid- ance only and are not tested. note 1: settling time measured while vrr = 1 and vr<3:0> transitions from 0000 to 1111 . 2: see section 7.11 comparator voltage reference for more information. dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c operating voltage v dd range 2.0v-5.5v sym. characteristic min typ? max units conditions v plvd plvd voltage lvdl<2:0> = 001 1.900 2.0 2.125 v lvdl<2:0> = 010 2.000 2.1 2.225 v lvdl<2:0> = 011 2.100 2.2 2.325 v lvdl<2:0> = 100 2.200 2.3 2.425 v lvdl<2:0> = 101 3.825 4.0 4.200 v lvdl<2:0> = 110 4.025 4.2 4.400 v lvdl<2:0> = 111 4.325 4.5 4.700 v *t plvds plvd settling time 50 25 sv dd = 5.0v v dd = 3.0v * these parameters are characterized but not tested ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 186 ? 2007 microchip technology inc. table 15-9: pic16f639 plvd characteristics : dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c operating voltage v dd range 2.0v-5.5v sym. characteristic min typ? max units conditions v plvd plvd voltage lvdl<2:0> = 001 1.900 2.0 2.100 v lvdl<2:0> = 010 2.000 2.1 2.200 v lvdl<2:0> = 011 2.100 2.2 2.300 v lvdl<2:0> = 100 2.200 2.3 2.400 v lvdl<2:0> = 101 3.825 4.0 4.175 v lvdl<2:0> = 110 4.025 4.2 4.375 v lvdl<2:0> = 111 4.325 4.5 4.675 v *t plvds plvd settling time 50 25 sv dd = 5.0v v dd = 3.0v * these parameters are characterized but not tested ? data in typ column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 187 pic12f635/pic16f636/639 15.11 ac characteristics: analog front-end for pic16f639 (industrial) ac characteristics standard operating conditions (unless otherwise stated) supply voltage 2.0v v dd 3.6v operating temperature -40c t amb +85c for industrial lc signal input sinusoidal 300 mv pp carrier frequency 125 khz lccom connected to v ss param no. sym. characteristic min typ? max units conditions af01 v sense lc input sensitivity 13 . 0 6m v pp v dd = 3.0v output enable filter disabled agcsig = 0 ; modmin = 00 (33% modulation depth setting) input = continuous wave (cw) output = logic level transition from low-to- high at sensitivity level for cw input. af02 v de _ q coil de-qing voltage - rf limiter (r flm ) must be active 3 5 vv dd = 3.0v, force i in = 5 a af03 r flm rf limiter turn-on resistance (lcx, lcy, lcz) 300 700 ohm v dd = 2.0v, v in = 8 vdc af04 s adj sensitivity reduction 0 -30 dbdb v dd = 3.0v no sensitivity reduction selected max reduction selected monotonic increment in attenuation value from setting = 0000 to 1111 by design af05 v in _ mod minimum modulation depth 75% 12% 50% 12% 25% 12% 12% 12% 6338 13 0 7550 25 12 8762 37 24 %% % % v dd = 3.0v af06 c tunx lcx tuning capacitor 44 0 63 82 pfpf v dd = 3.0v, config. reg. 1, bits <6:1> setting = 000000 63 pf +/- 30% config. reg. 1, bits <6:1> setting = 111111 63 steps, 1 pf/step monotonic increment in capacitor value from setting = 000000 to 111111 by design af07 c tuny lcy tuning capacitor 44 0 63 82 pfpf v dd = 3.0v, config. reg. 2, bits <6:1> setting = 000000 63 pf +/- 30% config. reg. 2, bits <6:1> setting = 111111 63 steps, 1 pf/step monotonic increment in capacitor value from setting = 000000 to 111111 by design af08 c tunz lcz tuning capacitor 44 0 63 82 pfpf v dd = 3.0v, config. reg. 3, bits<6:1> setting = 000000 63 pf +/- 30% config. reg. 3, bits<6:1> setting = 111111 63 steps, 1 pf/step monotonic increment in capacitor value from setting = 000000 to 111111 by design af09 f carrier carrier frequency 125 khz characterized at bench. af10 f mod input modulation frequency 10 khz input data rate, characterized at bench. af11 c_q q of trimming capacitors 50 * pf characterized at bench test af12 t dr demodulator charge time (delay time of demodulated output to rise) 5 0 sv dd = 3.0v mod depth setting = 50% input conditions: amplitude = 300 mv pp modulation depth = 80% af13 t df demodulator discharge time (delay time of demodulated output to fall) 5 0 sv dd = 3.0v mod depth setting = 50% input conditions: amplitude = 300 mv pp modulation depth = 80% * parameter is characterized but not tested. ? data in typ column is at 3.0v, 25c unless otherwise stated. these parameters are for design gu idance only and are not teste d. note 1: required output enable filter high time must account for input path analog delays (= t oeh - t dr + t df ). 2: required output enable filter low time must account for input path analog delays (= t oel + t dr - t df ). downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 188 ? 2007 microchip technology inc. af14 t lfdata r rise time of lfdata 0.5 sv dd = 3.0v time is measured from 10% to 90% of amplitude af15 t lfdata f fall time of lfdata 0.5 sv dd = 3.0v time is measured from 10% to 90% of amplitude af16 t agc agc initialization time 3.5 * ms time required for agc stabilization af17 t pagc high time after agc settling time 62.5 s equivalent to two internal clock cycle (f osc ) af18 t stab agc stabilization time plus high time (after agc settling time) (t agc +t pagc ) 4 ms agc stabilization time af19 t gap gap time after agc settling time 200 s typically 1 t e af20 t rdy time from exiting sleep or por to being ready to receive signal 5 0 * ms af21 t pres minimum time agc level must be held after receiving agc preserve command 5 * ms agc level must not change more than 10% during t pres . af22 f osc internal rc oscillator frequency (10%) 28.8 32 35.2 khz internal clock trimmed at 32 khz during test af23 t inact inactivity timer time-out 14.4 16 17.6 ms 512 cycles of rc oscillator @ f osc af24 t alarm alarm timer time-out 28.8 32 35.2 ms 1024 cycles of rc oscillator @ f osc af25 r lc lc pin input impedance lcx, lcy, lcz 1* mohm device in standby mode af26 c in lc pin input capacitance lcx, lcy, lcz 24 pf lccom grounded. vdd = 3.0v, f carrier = 125 khz af27 t e time element of pulse 100 s af28 t oeh minimum output enable filter high time oeh (bits config0<7:6> ) 01 = 1ms 10 = 2ms 11 = 4ms 00 = filter disabled 32 (~1ms) 64 (~2ms) 128 (~4ms) clock count rc oscillator = f osc viewed from the pin input: (note 1) af29 t oel minimum output enable filter low time oel (bits config0<5:4> ) 00 = 1ms 01 = 1ms 10 = 2ms 11 = 4ms 32 (~1ms) 32 (~1ms) 64 (~2ms) 128 (~4ms) clock count rc oscillator = f osc viewed from the pin input: (note 2) 15.11 ac characteristics: analog front-end for pic16f639 (industrial) (continued) ac characteristics standard operating conditions (unless otherwise stated) supply voltage 2.0v v dd 3.6v operating temperature -40c t amb +85c for industrial lc signal input sinusoidal 300 mv pp carrier frequency 125 khz lccom connected to v ss param no. sym. characteristic min typ? max units conditions * parameter is characterized but not tested. ? data in typ column is at 3.0v, 25c unless otherwise stated. these parameters are for design gu idance only and are not teste d. note 1: required output enable filter high time must account for input path analog delays (= t oeh - t dr + t df ). 2: required output enable filter low time must account for input path analog delays (= t oel + t dr - t df ). downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 189 pic12f635/pic16f636/639 af30 t oet maximum output enable filter period oeh oel t oeh t oel 01 00 = 1 ms 1 ms (filter 1) 01 01 = 1 ms 1 ms (filter 1) 01 10 = 1 ms 2 ms (filter 2) 01 11 = 1ms 4ms (filter 3) 10 00 = 2 ms 1 ms (filter 4) 10 01 = 2 ms 1 ms (filter 4) 10 10 = 2 ms 2 ms (filter 5) 10 11 = 2 ms 4 ms (filter 6) 11 00 = 4 ms 1 ms (filter 7) 11 01 = 4 ms 1 ms (filter 7) 11 10 = 4 ms 2 ms (filter 8) 11 11 = 4 ms 4 ms (filter 9) 00 xx = filter disabled 96 (~3ms) 96 (~3ms) 128 (~4ms) 192 (~6ms) 128 (~4ms) 128 (~4ms) 160 (~5ms) 250 (~8ms) 192 (~6ms) 192 (~6ms) 256 (~8ms) 320 (~10ms) clock count rc oscillator = f osc lfdata output appears as long as input signal level is greater than v sense . af31 i rssi rssi current output 100 1 10 100 a a a a v dd = 3.0v, v in = 0 to 4 v pp linearly increases with input signal amplitude. tested at v in = 40 mv pp , 400 mv pp , and 4v pp v in = 40 mv pp v in = 400 mv pp v in = 4 v pp af32 i rssi lr rssi current linearity -15 15 % tested at room temperature only 15.11 ac characteristics: analog front-end for pic16f639 (industrial) (continued) ac characteristics standard operating conditions (unless otherwise stated) supply voltage 2.0v v dd 3.6v operating temperature -40c t amb +85c for industrial lc signal input sinusoidal 300 mv pp carrier frequency 125 khz lccom connected to v ss param no. sym. characteristic min typ? max units conditions * parameter is characterized but not tested. ? data in typ column is at 3.0v, 25c unless otherwise stated. these parameters are for design gu idance only and are not teste d. note 1: required output enable filter high time must account for input path analog delays (= t oeh - t dr + t df ). 2: required output enable filter low time must account for input path analog delays (= t oel + t dr - t df ). downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 190 ? 2007 microchip technology inc. 15.12 spi timing: analog front-end (afe) for pic16f639 ac characteristics standard operating conditions (unless otherwise stated) supply voltage 2.0v v dd 3.6v operating temperature -40c t amb +85c for industrial lc signal input sinusoidal 300 mv pp carrier frequency 125 khz lccom connected to v ss param sym characteristic min typ? max units conditions af33 f sclk sclk frequency 3 mhz af34 tcssc cs fall to first sclk edge setup time 100 ns af35 t su sdi setup time 30 ns af36 t hd sdi hold time 50 ns af37 t hi sclk high time 150 ns af38 t lo sclk low time 150 ns af39 t do sdo setup time 150 ns af40 t sccs sclk last edge to cs rise setup time 100 ns af41 t csh cs high time 500 ns af42 t cs 1cs rise to sclk edge setup time 50 ns af43 t cs 0 sclk edge to cs fall setup time 50 ns sclk edge when cs is high af44 t spi r rise time of spi data (spi read command) 1 0 n sv dd = 3.0v. time is measured from 10% to 90% of amplitude af45 t spi f fall time of spi data (spi read command) 1 0 n sv dd = 3.0v. time is measured from 90% to 10% of amplitude * parameter is characterized but not tested. ? data in typ column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 191 pic12f635/pic16f636/639 16.0 dc and ac characteristics graphs and tables the graphs and tables provided in this section are for design guidance and are not tested . in some graphs or tables, the data presented are outside specified operating range (i.e., outside specified v dd range). this is for information only and devices are ensured to operate properly only within the specified range. typical represents the mean of the distribution at 25 c. maximum or minimum represents (mean + 3 ) or (mean - 3 ) respectively, where is a standard deviation, over each temperature range. figure 16-1: typical i dd vs. f osc over v dd (ec mode) note: the graphs and tables provided following this note are a statistical summary based on a limited number of samples and are provided for informational purposes only. the performance characteristics listed herein a re not tested or guaranteed. in some graphs or tables, the data presented may be outside the speci fied operating range (e.g., outside specified power supply range) and therefore, outside the warranted range. 3.0v 4.0v 5.0v 5.5v 2.0v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 1 mhz 2 mhz 4 mhz 6 mhz 8 mhz 10 mhz 12 mhz 14 mhz 16 mhz 18 mhz 20 mhz f osc i dd (ma) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 192 ? 2007 microchip technology inc. figure 16-2: maximum i dd vs. f osc over v dd (ec mode) figure 16-3: typical i dd vs. f osc over v dd (hs mode) ec mode 3.0v 4.0v 5.0v 2.0v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 1 mhz 2 mhz 4 mhz 6 mhz 8 mhz 10 mhz 12 mhz 14 mhz 16 mhz 18 mhz 20 mhz f osc i dd (ma) 5.5v typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typical idd vs fosc over vdd hs mode 3.0v 3.5v 4.0v 4.5v 5.0v 5.5v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4 mhz 10 mhz 16 mhz 20 mhz f osc i dd (ma) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 193 pic12f635/pic16f636/639 figure 16-4: maximum i dd vs. f osc over v dd (hs mode) figure 16-5: typical i dd vs. v dd over f osc (xt mode) maximum idd vs fosc over vdd hs mode 3.5v 4.0v 4.5v 5.0v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 4 mhz 10 mhz 16 mhz 20 mhz f osc i dd (ma) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 3.0v 5.5v xt mode 0 100 200 300 400 500 600 700 800 900 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 4 mhz 1 mhz downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 194 ? 2007 microchip technology inc. figure 16-6: maximum i dd vs. v dd over f osc (xt mode) figure 16-7: typical i dd vs. v dd over f osc (extrc mode) xt mode 0 200 400 600 800 1,000 1,200 1,400 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 4 mhz 1 mhz extrc mode 0 100 200 300 400 500 600 700 800 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd ( a) 1 mhz typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 4 mhz downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 195 pic12f635/pic16f636/639 figure 16-8: maximum i dd vs. v dd over f osc (extrc mode) figure 16-9: i dd vs. v dd over f osc (lfintosc mode, 31 khz) extrc mode 0 200 400 600 800 1,000 1,200 1,400 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 4 mhz 1 mhz lfintosc mode, 31khz typical maximum 0 10 20 30 40 50 60 70 80 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 196 ? 2007 microchip technology inc. figure 16-10: i dd vs. v dd over f osc (lp mode) figure 16-11: typical i dd vs. f osc over v dd (hfintosc mode) lp mode 0 10 20 30 40 50 60 70 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 32 khz maximum 32 khz typical hfintosc 2.0v 3.0v 4.0v 5.0v 5.5v 0 200 400 600 800 1,000 1,200 1,400 1,600 125 khz 250 khz 500 khz 1 mhz 2 mhz 4 mhz 8 mhz f osc i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 197 pic12f635/pic16f636/639 figure 16-12: maximum i dd vs. f osc over v dd (hfintosc mode) figure 16-13: typical i pd vs. v dd (sleep mode, all peripherals disabled) hfintosc 2.0v 3.0v 4.0v 5.0v 5.5v 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 125 khz 250 khz 500 khz 1 mhz 2 mhz 4 mhz 8 mhz f osc i dd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typical (sleep mode all peripherals disabled) 0.0 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 198 ? 2007 microchip technology inc. figure 16-14: maximum i pd vs. v dd (sleep mode, all peripherals disabled) figure 16-15: comparator i pd vs. v dd (both comparators enabled) maximum (sleep mode all peripherals disabled) max. 125c max. 85c 0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0 18.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) maximum: mean + 3 typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 0 20 40 60 80 100 120 140 160 180 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) maximum typical typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 199 pic12f635/pic16f636/639 figure 16-16: bor i pd vs. v dd over temperature figure 16-17: typical wdt i pd vs. v dd over temperature 0 20 40 60 80 100 120 140 160 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) maximum typical typical 0.0 0.5 1.0 1.5 2.0 2.5 3.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) typical: statistical mean @25c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 200 ? 2007 microchip technology inc. figure 16-18: maximum wdt i pd vs. v dd over temperature figure 16-19: wdt period vs. v dd over temperature maximum max. 125c max. 85c 0.0 5.0 10.0 15.0 20.0 25.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) minimum typical 10 12 14 16 18 20 22 24 26 28 30 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time (ms) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) max. (125c) max. (85c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 201 pic12f635/pic16f636/639 figure 16-20: wdt period vs. temperature over v dd (5.0v) figure 16-21: cv ref i pd vs. v dd over temperature (high range) vdd = 5v 10 12 14 16 18 20 22 24 26 28 30 -40c 25c 85c 125c temperature ( c) time (ms) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) maximum typical minimum high range typical max. 85c 0 20 40 60 80 100 120 140 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) max. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 202 ? 2007 microchip technology inc. figure 16-22: cv ref i pd vs. v dd over temperature (low range) figure 16-23: v ol vs. i ol over temperature (v dd = 3.0v) typical max. 85c 0 20 40 60 80 100 120 140 160 180 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( a) max. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) (vdd = 3v, -40c to 125c) 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 i ol (ma) v ol (v) max. 85c max. 125c typical 25c min. -40c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 203 pic12f635/pic16f636/639 figure 16-24: v ol vs. i ol over temperature (v dd = 5.0v) figure 16-25: v oh vs. i oh over temperature (v dd = 3.0v) 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 i ol (ma) v ol (v) typical: statistical mean @25c maximum: meas + 3 (-40c to 125c) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) max. 85c typ. 25c min. -40c max. 125c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 i oh (ma) v oh (v) typ. 25c max. -40c min. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 204 ? 2007 microchip technology inc. figure 16-26: v oh vs. i oh over temperature (v dd = 5.0v) figure 16-27: ttl input threshold v in vs. v dd over temperature (vdd = 5v, -40c to 125c) 3.0 3.5 4.0 4.5 5.0 5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 i oh (ma) v oh (v) max. -40c typ. 25c min. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) (ttl input, -40c to 125c) 0.5 0.7 0.9 1.1 1.3 1.5 1.7 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) v in (v) typ. 25c max. -40c min. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 205 pic12f635/pic16f636/639 figure 16-28: schmitt trigger input threshold v in vs. v dd over temperature figure 16-29: t1osc i pd vs. v dd over temperature (32 khz) (st input, -40c to 125c) 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) v in (v) v ih max. 125c v ih min. -40c v il min. 125c v il max. -40c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typ. 25c max. 85c max. 125c 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd ( m a) maximum: mean + 3 (-40c to 125c) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 206 ? 2007 microchip technology inc. figure 16-30: comparator response time (rising edge) figure 16-31: comparator response time (falling edge) 531 806 0 100 200 300 400 500 600 700 800 900 1000 2.0 2.5 4.0 5.5 v dd (v) response time (ns) max. 85c typ. 25c min. -40c max. 125c note: v- input = transition from v cm + 100 m v to v cm - 20 m v v+ input = v cm v cm = v dd - 1.5v)/2 0 100 200 300 400 500 600 700 800 900 1000 2.0 2.5 4.0 5.5 v dd (v) response time (ns) max. 85c typ. 25c min. -40c max. 125c note: v- input = transition from v cm - 100 m v to v cm + 20 m v v+ input = v cm v cm = v dd - 1.5v)/2 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 207 pic12f635/pic16f636/639 figure 16-32: lfintosc frequency vs. v dd over temperature (31 khz) figure 16-33: typical hfintosc start-up times vs. v dd over temperature lfintosc 31khz 0 5,000 10,000 15,000 20,000 25,000 30,000 35,000 40,000 45,000 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) frequency (hz) max. -40c typ. 25c min. 85c min. 125c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) 0 2 4 6 8 10 12 14 16 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) 85c 25c -40c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 208 ? 2007 microchip technology inc. figure 16-34: maximum hfintosc start-up times vs. v dd over temperature figure 16-35: minimum hfintosc start-up times vs. v dd over temperature -40c to +85c 0 5 10 15 20 25 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) -40c 85c 25c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) -40c to +85c 0 1 2 3 4 5 6 7 8 9 10 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) -40c 25c 85c typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 209 pic12f635/pic16f636/639 figure 16-36: typical hfintosc frequency change vs. v dd (25c) figure 16-37: typical hfintosc frequency change over device v dd (85c) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 210 ? 2007 microchip technology inc. figure 16-38: typical hfintosc frequency change vs. v dd (125c) figure 16-39: typical hfintosc frequency change vs. v dd (-40c) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 211 pic12f635/pic16f636/639 17.0 packaging information 17.1 package marking information * standard pic device marking consists of microchip part number, year code, week code and trace ability code. for pic device marking beyond this, certain price adders apply. please check with your microch ip sales office. for qtp devices, any special marking adders are included in qtp price. xxxxxnnn 8-lead pdip xxxxxxxx yyww 017 example 12f635/p 0610 8-lead soic xxxxxxxx xxxxyyww nnn example 12f635/ sn 0610 017 legend: xx...x customer-specific information y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week 01) nnn alphanumeric traceability code pb-free jedec designator for matte tin (sn) * this package is pb-free. the pb-free jedec designator ( ) can be found on the outer packaging for this package. note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. 3 e 3 e xxxxxx 8-lead dfn (4x4x0.9 mm) xxxxxx yyww nnn pic12f example 635/mf 0610 017 xxxxxxx 8-lead dfn-s (6x5 mm) xxxxxxx xxyyww nnn picxxf example xxx-i/ mf0610 017 3 e 3 e downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 212 ? 2007 microchip technology inc. 17.1 package marking information (continued) 14-lead soic xxxxxxxxxxx xxxxxxxxxxx yywwnnn example pic16f636 -i/sl 0610017 14-lead tssop xxxxxxxx yyww nnn example f636/st 0610 017 20-lead ssop xxxxxxxxxxx xxxxxxxxxxx yywwnnn example pic16f639 -i/ss 0610017 xxxxxxx 16-lead qfn xxxxxxx yywwnnn 16f636 example -i/ml 0610017 14-lead pdip xxxxxxxxxxxxxx xxxxxxxxxxxxxx yywwnnn example pic16f636-i/p 0610017 3 e 3 e downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 213 pic12f635/pic16f636/639 17.2 package details the following sections give the technical details of the packages. 8-lead plastic dual in-line (p or pa) C 300 mil body [pdip] notes: 1. pin 1 visual index feature may vary, but must be located with the hatched area. 2. significant characteristic. 3. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010" per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units inches dimension limits min nom max number of pins n 8 pitch e .100 bsc top to seating plane a C C .210 molded package thickness a2 .115 .130 .195 base to seating plane a1 .015 C C shoulder to shoulder width e .290 .310 .325 molded package width e1 .240 .250 .280 overall length d .348 .365 .400 tip to seating plane l .115 .130 .150 lead thickness c .008 .010 .015 upper lead width b1 .040 .060 .070 lower lead width b .014 .018 .022 overall row spacing eb C C .430 n e1 note 1 d 12 3 a a1 a2 l b1 b e e e b c microchip technology drawing c04-018 b downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 214 ? 2007 microchip technology inc. 8-lead plastic small outline (sn or oa) C narrow, 3.90 mm body [soic] n otes: 1 . pin 1 visual index feature may vary, but must be located within the hatched area. 2 . significant characteristic. 3 . dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.15 mm per side. 4 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 8 pitch e 1.27 bsc overall height a C C 1.75 molded package thickness a2 1.25 C C standoff a1 0.10 C 0.25 overall width e 6.00 bsc molded package width e1 3.90 bsc overall length d 4.90 bsc chamfer (optional) h 0.25 C 0.50 foot length l 0.40 C 1.27 footprint l1 1.04 ref foot angle 0 C 8 lead thickness c 0.17 C 0.25 lead width b 0.31 C 0.51 mold draft angle top 5 C 15 mold draft angle bottom 5 C 15 d n e e e1 note 1 12 3 b a a1 a2 l l1 c h h microchip technology drawing c04-057 b downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 215 pic12f635/pic16f636/639 8-lead plastic dual flat, no lead package (md) C 4x4x0.9 mm body [dfn] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. package may have one or more exposed tie bars at ends. 3. package is saw singulated. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 8 pitch e 0.80 bsc overall height a 0.80 0.90 1.00 standoff a1 0.00 0.02 0.05 contact thickness a3 0.20 ref overall length d 4.00 bsc exposed pad width e2 0.00 2.20 2.80 overall width e 4.00 bsc exposed pad length d2 0.00 3.00 3.60 contact width b 0.25 0.30 0.35 contact length l 0.30 0.55 0.65 contact-to-exposed pad k 0.20 C C d n e note 1 1 2 a 3 a a1 note 2 note 1 d2 1 2 e2 l n e b k exposed pad top vie bottom vie microchip technology drawing c04-131 c downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 216 ? 2007 microchip technology inc. 8-lead plastic dual flat, no lead package (mf) C 6x5 mm body [dfn-s] n otes: 1 . pin 1 visual index feature may vary, but must be located within the hatched area. 2 . package may have one or more exposed tie bars at ends. 3 . package is saw singulated. 4 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 8 pitch e 1.27 bsc overall height a 0.80 0.85 1.00 standoff a1 0.00 0.01 0.05 contact thickness a3 0.20 ref overall length d 5.00 bsc overall width e 6.00 bsc exposed pad length d2 3.90 4.00 4.10 exposed pad width e2 2.20 2.30 2.40 contact width b 0.35 0.40 0.48 contact length l 0.50 0.60 0.75 contact-to-exposed pad k 0.20 C C note 2 a1 a a 3 note 1 12 e n d exposed pad note 1 2 1 e2 l n e b k bottom vie top vie d2 microchip technology drawing c04-122 b downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 217 pic12f635/pic16f636/639 14-lead plastic dual in-line (p or pd) C 300 mil body [pdip] n otes: 1 . pin 1 visual index feature may vary, but must be located with the hatched area. 2 . significant characteristic. 3 . dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010" per side. 4 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units inches dimension limits min nom max number of pins n 14 pitch e .100 bsc top to seating plane a C C .210 molded package thickness a2 .115 .130 .195 base to seating plane a1 .015 C C shoulder to shoulder width e .290 .310 .325 molded package width e1 .240 .250 .280 overall length d .735 .750 .775 tip to seating plane l .115 .130 .150 lead thickness c .008 .010 .015 upper lead width b1 .045 .060 .070 lower lead width b .014 .018 .022 overall row spacing eb C C .430 n e1 d note 1 12 3 e c e b a2 l a a1 b1 b e microchip technology drawing c04-005 b downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 218 ? 2007 microchip technology inc. 14-lead plastic small outline (sl or od) C narrow, 3.90 mm body [soic] n otes: 1 . pin 1 visual index feature may vary, but must be located within the hatched area. 2 . significant characteristic. 3 . dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.15 mm per side. 4 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 14 pitch e 1.27 bsc overall height a C C 1.75 molded package thickness a2 1.25 C C standoff a1 0.10 C 0.25 overall width e 6.00 bsc molded package width e1 3.90 bsc overall length d 8.65 bsc chamfer (optional) h 0.25 C 0.50 foot length l 0.40 C 1.27 footprint l1 1.04 ref foot angle 0 C 8 lead thickness c 0.17 C 0.25 lead width b 0.31 C 0.51 mold draft angle top 5 C 15 mold draft angle bottom 5 C 15 note 1 n d e e1 1 2 3 b e a a1 a2 l l1 c h h microchip technology drawing c04-065 b downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 219 pic12f635/pic16f636/639 14-lead plastic thin shrink small outline (st) C 4.4 mm body [tssop] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.15 mm per side. 3. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 14 pitch e 0.65 bsc overall height a C C 1.20 molded package thickness a2 0.80 1.00 1.05 standoff a1 0.05 C 0.15 overall width e 6.40 bsc molded package width e1 4.30 4.40 4.50 molded package length d 4.90 5.00 5.10 foot length l 0.45 0.60 0.75 footprint l1 1.00 ref foot angle 0 C 8 lead thickness c 0.09 C 0.20 lead width b 0.19 C 0.30 note 1 d n e e1 1 2 e b c a a1 a2 l1 l microchip technology drawing c04-087 b downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 220 ? 2007 microchip technology inc. 16-lead plastic quad flat, no lead package (ml) C 4x4x0.9 mm body [qfn] n otes: 1 . pin 1 visual index feature may vary, but must be located within the hatched area. 2 . package is saw singulated. 3 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 16 pitch e 0.65 bsc overall height a 0.80 0.90 1.00 standoff a1 0.00 0.02 0.05 contact thickness a3 0.20 ref overall width e 4.00 bsc exposed pad width e2 2.50 2.65 2.80 overall length d 4.00 bsc exposed pad length d2 2.50 2.65 2.80 contact width b 0.25 0.30 0.35 contact length l 0.30 0.40 0.50 contact-to-exposed pad k 0.20 C C d e n 21 exposed pad d2 e2 2 1 e b k n note 1 a 3 a1 a l top vie bottom vie microchip technology drawing c04-127 b downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 221 pic12f635/pic16f636/639 20-lead plastic shrink small outline (ss) C 5.30 mm body [ssop] n otes: 1 . pin 1 visual index feature may vary, but must be located within the hatched area. 2 . dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.20 mm per side. 3 . dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 20 pitch e 0.65 bsc overall height a C C 2.00 molded package thickness a2 1.65 1.75 1.85 standoff a1 0.05 C C overall width e 7.40 7.80 8.20 molded package width e1 5.00 5.30 5.60 overall length d 6.90 7.20 7.50 foot length l 0.55 0.75 0.95 footprint l1 1.25 ref lead thickness c 0.09 C 0.25 foot angle 0 4 8 lead width b 0.22 C 0.38 l l1 a2 c e b a1 a 12 note 1 e1 e d n microchip technology drawing c04-072 b downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 222 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 223 pic12f635/pic16f636/639 the microchip web site microchip provides online support via our www site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support C data sheets and errata, application notes and sample programs, design resources, users guides and hardware support documents, latest software releases and archived software ? general technical support C frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip C product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchips customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support ? development systems information line customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 224 ? 2007 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in wh ich our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this docume nt. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds41232d pic12f635/pic16f636/639 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document? downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 225 pic12f635/pic16f636/639 appendix a: data sheet revision history revision a this is a new data sheet. revision b added pic16f639 to the data sheet. revision c (12/2006) added characterization data; updated package drawings; added comparator voltage reference section. revision d (03/2007) replaced package drawings (rev. am); replaced development support section. updated product id system. downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 226 ? 2007 microchip technology inc. notes: downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 227 pic12f635/pic16f636/639 indexa absolute maximum ratings .............................................. 163 ac characteristics analog front-end (afe) for pic16f639 ................... 187 industrial and extended .......................................... .. 179 load conditions ............................................... ......... 178 agc settling ....................................................................... 99 analog front-end configuration registers summary table ................................................ 123 analog front-end (afe) ..................................................... 97 a/d data conversion of rssi signal........................ 118 afe status register bit condition ............................ 127 agc .............................................................. 98, 99, 106 agc preserve........................................................... 106 battery back-up and batteryless operation.............. 110 block diagrams bidirectional pke system application example 102 functional ............................................... .......... 100 lc input path ............................................. ....... 101 output enable filter timing .............................. 103 output enable filter timing (detailed) ............. 104 carrier clock detector ................................................ 98 carrier clock output ................................................. 114 examples .......................................................... 115 command decoder/controller .................................. 121 configuration registers ............................................ 122 data slicer .................................................................. 98 demodulator ....................................................... 98, 111 de-qing of antenna circuit ...................................... 110 error detection.......................................................... 109 factory calibration.................................................... 110 fixed gain amplifiers.................................................. 98 input sensitivity control ......................................... ... 105 lf field powering/battery back-up examples .......................................................... 110 lfdata output selection......................................... 111 case i ............................................................... 112 case ii .............................................................. 112 low current modes operating .......................................................... 109 sleep................................................................. 109 standby................................................. ............ 109 modulation circuit .............................................. ......... 97 modulation depth................................................ ...... 107 examples .......................................................... 108 output enable filter ........................................... ......... 98 configurable smart ........................................... 103 output enable filter timing (table).......................... 105 power-on reset ........................................................ 111 rf limiter ................................................................... 97 rssi.................................................................... 98, 116 output path diagram ........................................ 116 power-up sequence diagram........................... 118 spi read sequence diagram........................... 120 spi write sequence diagram ........................... 119 rssi output current vs. input signal level example ............................................................ 117 sensitivity control ....................................................... 97 soft reset ................................................................. 107 spi interface timing diagram................................... 122 timers ................................................................... 98, 99 alarm .................................................................. 99 auto channel selection ...................................... 98 inactivity ............................................................. 99 period ................................................................. 99 preamble counters............................................. 99 pulse width ........................................................ 99 rc oscillator ...................................................... 98 tuning capacitor ........................................... ............. 97 variable attenuator............................................. ........ 97 analog input connection considerations ........................... 73 assembler mpasm assembler .................................................. 160 b block diagrams analog input model................................................ ..... 73 clock source .............................................................. 35 comparator................................................................. 71 comparator c1 ........................................................... 72 comparator c2 ........................................................... 72 comparator modes.............................................. ....... 75 crystal operation........................................................ 38 external rc mode ...................................................... 39 fail-safe clock monitor (fscm)................................. 45 functional (afe)............................................. .......... 100 in-circuit serial programming connection ............... 147 interrupt logic............................................ ............... 140 on-chip reset circuit............................................... 131 pic12f635 device .............................................. ......... 9 pic16f636 device .............................................. ....... 10 pic16f639 device .............................................. ....... 11 ra0 pin ...................................................................... 52 ra1 pin ...................................................................... 53 ra2 pin ...................................................................... 53 ra3 pin ...................................................................... 54 ra4 pin ...................................................................... 55 ra5 pin ...................................................................... 55 rc0 and rc1 pins .............................................. ....... 58 rc2, rc3 and rc5 pins ............................................ 58 rc4 pin ...................................................................... 59 recommended mclr circuit................................... 133 resonator operation ............................................... ... 38 timer1 ........................................................................ 65 tmr0/wdt prescaler ................................................ 61 watchdog timer (wdt)......................................... ... 143 brown-out reset (bor).................................................... 134 associated ................................................................ 135 specifications ........................................................... 183 timing and characteristics ................................. 87, 182 c c compilers mplab c18.............................................................. 160 mplab c30.............................................................. 160 clock sources external modes............................................... ............ 37 ec ...................................................................... 37 hs ...................................................................... 38 lp ....................................................................... 38 ost .................................................................... 37 rc ...................................................................... 39 xt ....................................................................... 38 internal modes.............................................. .............. 39 frequency selection.......................................... . 41 hfintosc ......................................................... 39 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 228 ? 2007 microchip technology inc. intosc .............................................................. 39 intoscio........................................................... 39 lfintosc .......................................................... 41 clock switching................................................................... 43 cmcon0 register .............................................................. 80 cmcon1 register .............................................................. 82 code examples assigning prescaler to timer0 .................................... 62 assigning prescaler to wdt ....................................... 62 data eeprom read .................................................. 93 data eeprom write .................................................. 93 indirect addressing ..................................................... 32 initializing porta....................................................... 47 initializing portc....................................................... 57 saving status and w registers in ram ................... 142 ultra low-power wake-up initialization ...................... 51 write verify ................................................................. 93 code protection ............................................... ................. 146 comparator ......................................................................... 71 associated registers.................................................... 85 c2out as t1 gate ..................................................... 81 configurations............................................................. 74 i/o operating modes............................................ ....... 74 interrupts..................................................................... 77 operation .............................................................. 71, 76 operation during sleep .............................................. 79 response time ............................................... ............ 77 synchronizing cxout w/timer1................................. 81 comparator voltage reference (cv ref ) response time ............................................... ............ 77 specifications ........................................... ......... 185, 186 comparator voltage reference (cv ref ) ............................ 83 effects of a reset........................................................ 79 specifications............................................................ 185 comparators c2out as t1 gate ..................................................... 66 effects of a reset........................................................ 79 specifications............................................................ 185 config register.............................................................. 130 configuration bits.............................................................. 129 cpu features ................................................................... 129 customer change notification service ............................. 223 customer notification service........................................... 223 customer support ............................................... .............. 223 d data eeprom memory associated registers .................................................. 94 code protection ............................................... ..... 91, 94 protection against spurious write .............................. 94 using ........................................................................... 93 data memory....................................................................... 17 dc and ac characteristics graphs and tables .............................................. ..... 191 dc characteristics extended (pic12f635/pic16f636) .......................... 169 industrial (pic12f635/pic16f636)........................... 167 industrial (pic16f639) ........................................... ... 174 industrial/extended (pic12f635/pic16f636) .. 166, 171 industrial/extended (pic16f639)...................... 173, 175 development support ............................................... ........ 159 device overview ................................................................... 9 e eeadr register ................................................................. 91 eecon1 (eeprom control 1) register ............................ 92 eecon1 register............................................................... 92 eecon2 (eeprom control 2) register ............................ 92 eedat register ................................................................. 91 eeprom data memory reading .................................................. .................... 93 write verify ................................................................. 93 writing ........................................................................ 93 electrical specifications .................................................... 163 errata .................................................................................... 7 f fail-safe clock monitor .................................................. .... 45 fail-safe condition clearing....................................... 45 fail-safe detection ..................................................... 45 fail-safe operation..................................................... 45 reset or wake-up from sleep .................................... 45 firmware instructions ....................................................... 149 fuses. see configuration bits g general purpose register (gpr) file ................................ 18 i id locations...................................................................... 146 in-circuit debugger.............................................. ............. 147 in-circuit serial programming (icsp)............................... 147 indirect addressing, indf and fsr registers ................... 32 instruction format............................................................. 149 instruction set................................................................... 149 addlw..................................................................... 151 addwf..................................................................... 151 andlw..................................................................... 151 andwf..................................................................... 151 bcf .......................................................................... 151 bsf........................................................................... 151 btfsc ...................................................................... 151 btfss ...................................................................... 152 call......................................................................... 152 clrf ........................................................................ 152 clrw ....................................................................... 152 clrwdt .................................................................. 152 comf ....................................................................... 152 decf ........................................................................ 152 decfsz ................................................................... 153 goto ....................................................................... 153 incf ......................................................................... 153 incfsz..................................................................... 153 iorlw ...................................................................... 153 iorwf...................................................................... 153 movf ....................................................................... 154 movlw .................................................................... 154 movwf .................................................................... 154 nop .......................................................................... 154 retfie ..................................................................... 155 retlw ..................................................................... 155 return................................................................... 155 rlf ........................................................................... 156 rrf .......................................................................... 156 sleep ...................................................................... 156 sublw ..................................................................... 156 subwf..................................................................... 157 swapf ..................................................................... 157 xorlw .................................................................... 157 xorwf .................................................................... 157 summary table ........................................................ 150 intcon register................................................................ 28 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 229 pic12f635/pic16f636/639 internal oscillator block intosc specifications........................................... . 180, 181 internet address................................................................ 223 interrupts........................................................................... 139 associated registers ................................................ 141 comparator ................................................................. 77 context saving.......................................................... 142 data eeprom memory write .................................... 92 interrupt-on-change............................................ ........ 50 porta interrupt-on-change ..................................... 140 ra2/int .................................................................... 139 timer0....................................................................... 140 tmr1 .......................................................................... 67 intosc specifications .......................................... ... 180, 181 ioca register..................................................................... 50 kk ee l oq ............................................................................... 95 l load conditions ............................................... ................. 178 mmclr ................................................................................ 132 internal ...................................................................... 132 memory organization............................................ .............. 17 data ............................................................................ 17 data eeprom memory.............................................. 91 program ...................................................................... 17 microchip internet web site .............................................. 223 mplab asm30 assembler, linker, librarian ................... 160 mplab icd 2 in-circuit debugger ................................... 161 mplab ice 2000 high-performance universal in-circuit emulator .................................................... 161 mplab integrated development environment software .. 159 mplab pm3 device programmer .................................... 161 mplab real ice in-circuit emulator system................. 161 mplink object linker/mplib object librarian ................ 160 o opcode field descriptions ............................................. 149 option register................................................................ 27 option_reg register ...................................................... 63 osccon register.............................................................. 36 oscillator associated registers.............................................. 46, 69 oscillator module ................................................................ 35 ec ............................................................................... 35 hfintosc.................................................................. 35 hs ............................................................................... 35 intosc ...................................................................... 35 intoscio................................................................... 35 lfintosc .................................................................. 35 lp................................................................................ 35 rc............................................................................... 35 rcio ........................................................................... 35 xt ............................................................................... 35 oscillator parameters ....................................................... 180 oscillator specifications.................................................... 179 oscillator start-up timer (ost) specifications............................................................ 183 oscillator switching fail-safe clock monitor............................................... 45 two-speed clock start-up.......................................... 43 osctune register ............................................................ 40 p packaging ......................................................................... 211 details....................................................................... 213 marking..................................................................... 211 pcl and pclath................................................ ............... 32 stack........................................................................... 32 pcon register ................................................................... 31 picstart plus development programmer..................... 162 pie1 register ..................................................................... 29 pin diagrams ............................................................ 3, 4, 5, 6 pinout descriptions pic12f635 ................................................................. 12 pic16f636 ................................................................. 13 pic16f639 ................................................................. 14 pir1 register ..................................................................... 30 plvd associated registers.................................................. 89 porta ............................................................................... 47 additional pin functions ........................................... .. 47 interrupt-on-change ........................................... 50 ultra low-power wake-up............................ 47, 51 weak pull-down.................................................. 47 weak pull-up ...................................................... 47 associated registers.................................................. 56 pin descriptions and diagrams .................................. 52 ra0/c1in+/icspdat/ulpwu pin............................. 52 ra1/c1in-/vref/icspclk pin .................................... 53 ra2/t0cki/int/c1out pin ....................................... 53 ra3/mclr /v pp p in .................................................... 54 ra4/t1g /osc2/clkout pin .................................... 55 ra5/t1cki/osc1/clkin pin..................................... 55 specifications ........................................................... 181 porta register ................................................................. 48 portc ............................................................................... 57 associated registers.................................................. 59 rc0/c2in+ pin ........................................................... 58 rc2 pin ...................................................................... 58 rc3 pin ...................................................................... 58 rc4/c2out pin ......................................................... 59 rc5 pin ...................................................................... 58 specifications ........................................................... 181 portc register................................................................. 57 power control (pcon) register....................................... 135 power-down mode (sleep)............................................... 145 power-on reset ................................................................ 132 power-up timer (pwrt) .................................................. 132 specifications ........................................................... 183 precision internal oscillator parameters .......................... 181 prescaler shared wdt/timer0................................................... 62 switching prescaler assignment ................................ 62 product identification .......................................... .............. 231 program memory ................................................................ 17 program memory map and stack pic12f635 ................................................................. 17 pic16f636/639 .............................................. ............ 17 programmable low-voltage detect (plvd) module .......... 87 programming, device instructions.................................. .. 149 r reader response................................................. ............ 224 read-modify-write operations ......................................... 149 registers analog front-end (afe) afe status register 7 .................................. 127 downloaded from: http:///
pic12f635/pic16f636/639 ds41232d-page 230 ? 2007 microchip technology inc. column parity register 6 .................................. 126 configuration register 0 ................................... 123 configuration register 1 ................................... 124 configuration register 2 ................................... 124 configuration register 3 ................................... 125 configuration register 4 ................................... 125 configuration register 5 ................................... 126 cmcon0 (comparator control 0) .............................. 80 cmcon0 (comparator control) register ................... 79 cmcon1 (comparator control 1) .............................. 82 cmcon1 (comparator control) register ................... 82 config (configuration word).................................. 130 eeadr (eeprom address) ...................................... 91 eecon1 (eeprom control 1)................................... 92 eedat (eeprom data) ............................................ 91 intcon (interrupt control) ......................................... 28 ioca (interrupt-on-change porta) ........................... 50 lvdcon (low-voltage detect control)...................... 89 option_reg (option) ........................................... 27 option_reg (option) .............................................. 63 osccon (oscillator control) ..................................... 36 osctune (oscillator tuning) .................................... 40 pcon (power control register) ................................. 31 pie1 (peripheral interrupt enable 1) ........................... 29 pir1 (peripheral interrupt request 1) ........................ 30 porta........................................................................ 48 portc ....................................................................... 57 reset values............................................................. 137 reset values (special registers) ............................. 138 status ...................................................................... 26 t1con ........................................................................ 68 trisa (tri-state porta) ........................................... 48 trisc (tri-state portc) .......................................... 57 vrcon (voltage reference control) ......................... 84 wda (weak pull-up/pull-down direction porta)...... 49 wdtcon (watchdog timer control)........................ 144 wpuda (weak pull-up/pull-down enable porta).... 49 reset................................................................................. 131 revision history ................................................................ 2 25 s software simulator (mplab sim)..................................... 160 special function registers (sfr)....................................... 18 maps pic12f635.......................................................... 19 pic16f636/639............................................... .... 20 summary pic12f635, bank 0............................................. 21 pic12f635, bank 1............................................. 22 pic12f635/pic16f636/639, bank 2 .................. 25 pic16f636/639, bank 0...................................... 23 pic16f636/639, bank 1...................................... 24 spi timing analog front-end (afe) for pic16f639 ................... 190 status register................................................................ 26 t t1con register.................................................................. 68 thermal considerations .................................................... 177 time-out sequence............................................ ............... 135 timer0 ................................................................................. 61 associated registers .................................................. 63 external clock............................................................. 62 interrupt....................................................................... 63 operation .............................................................. 61, 64 specifications............................................................ 184 t0cki ......................................................................... 62 timer1................................................................................. 64 associated registers ................................................... 69 asynchronous counter mode ..................................... 66 reading and writing ........................................... 66 interrupt ...................................................................... 67 modes of operation .................................................... 64 operation during sleep .............................................. 67 oscillator..................................................................... 66 prescaler .................................................................... 66 specifications ........................................................... 184 timer1 gate inverting gate ..................................................... 66 selecting source .......................................... 66, 81 synchronizing cxout w/timer1 ........................ 81 tmr1h register ......................................................... 64 tmr1l register.......................................................... 64 timers timer1 t1con ............................................................... 68 timing diagrams brown-out reset (bor)...................................... 87, 182 brown-out reset situations ...................................... 134 clkout and i/o ............................................. ......... 181 clock timing ............................................................. 179 comparator output ..................................................... 71 fail-safe clock monitor (fscm)................................. 46 int pin interrupt ....................................................... 141 internal oscillator switch timing ................................ 42 reset, wdt, ost and power-up timer ................... 182 time-out sequence on power-up (delayed mclr ) . 136 time-out sequence on power-up (mclr with v dd ) 136 timer0 and timer1 external clock ........................... 184 timer1 incrementing edge ......................................... 67 two speed start-up.......................................... .......... 44 wake-up from sleep through interrupt ..................... 146 timing parameter symbology .......................................... 178 trisa ................................................................................. 47 trisa register................................................................... 48 trisc register................................................................... 57 two-speed clock start-up mode........................................ 43 u ultra low-power wake-up................................ 13, 14, 47 , 51 v voltage reference. see comparator voltage reference (cv ref ) voltage references associated registers ................................................... 85 w wake-up from sleep ......................................................... 145 wake-up reset (wur) ..................................................... 132 wake-up using interrupts.................................................. 145 watchdog timer (wdt)......................................... ........... 143 associated registers ................................................ 144 control ...................................................................... 143 oscillator................................................................... 143 specifications ........................................................... 183 wda register ..................................................................... 49 wdtcon register ........................................................... 144 wpuda register ................................................................ 49 www address ................................................................. 223 www, on-line support .................... ................................... 7 downloaded from: http:///
? 2007 microchip technology inc. ds41232d-page 231 pic12f635/pic16f636/639 product identification system to order or obtain information, e. g., on pricing or delivery, refer to the factory or the listed sales office . part no. x /xx xxx pattern package temperature range device device: pic12f635 (1, 2) , pic16f636 (1, 2) , pic16f639 (1, 2) v dd range 2.0v to 5.5v temperature range: i= - 4 0 c to +85 c (industrial) e= - 4 0 c to +125 c (extended) package: md = dual-flat, no leads, 8-pin (4x4x0.9 mm) mf = dual-flat, no leads, saw sing. (6x5 mm) ml = dual-flat, no leads, 16-pin (4x4x0.9 mm) p = plastic dip (300 mil body, 5.30 mm) sl = 14-lead small outline (3.90 mm) sn = 8-lead small outline (3.90 mm) ss = 20-lead plastic shrink small outline (5.30 mm) st = 14-lead thin shrink small outline (4.4 mm) pattern: 3-digit pattern code for qtp (blank otherwise) examples: a) pic12f635-e/p 301 = extended temp., pdip package, 20 mhz, qtp pattern #301 b) pic12f635-i/s = industrial temp., soic package, 20 mhz note 1: f = standard voltage range 2: t = in tape and reel plcc. downloaded from: http:///
ds41232d-page 232 ? 2007 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway habour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - fuzhou tel: 86-591-8750-3506 fax: 86-591-8750-3521 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - shunde tel: 86-757-2839-5507 fax: 86-757-2839-5571 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7250 fax: 86-29-8833-7256 asia/pacific india - bangalore tel: 91-80-4182-8400 fax: 91-80-4182-8422 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - gumi tel: 82-54-473-4301 fax: 82-54-473-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - penang tel: 60-4-646-8870 fax: 60-4-646-5086 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 12/08/06 downloaded from: http:///


▲Up To Search▲   

 
Price & Availability of PIC12F635-ISNV04

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X